Skip to content

Symlinks

Index

symlinks::points_at

Predicate: does the given symlink already point at the canonicalized target? True if the link exists AND its canonical resolution equals the canonical resolution of the target.

Arguments

  • $1 (link): path
  • $2 (target): path

Exit codes

  • 0: if link points at target
  • 1: otherwise

symlinks::exists

Return true if the given path exists and is a symbolic link.

Arguments

  • $1 (symlink): path

symlinks::get_target

Print the target of a symbolic link; dies if the symlink does not exist. Output: stdout — symlink target path

Arguments

  • $1 (symlink): path

symlinks::find_broken

List broken (dangling) symlinks under a directory. Uses the find -L ... -type l idiom: with -L, working links resolve to their target's type and drop out, leaving only danglers as -type l.

Arguments

  • $1 (dir): optional directory to scan (default ".")

Output on stdout

  • one broken-symlink path per line; empty if none found

Create a symbolic link from a file to a link path, prompting if the destination already exists. No-ops if the link already points to the correct target.

Arguments

  • $1 (target): file path
  • $2 (link): path to create

Create a symbolic link from a directory to a link path, prompting if the destination already exists. No-ops if the link already points to the correct target.

Arguments

  • $1 (target): directory path
  • $2 (link): path to create