Path env

sys_path_contains

Return 0 if the given directory is in PATH.

Example

sys_path_contains /usr/local/bin   # 0 if present

Arguments

  • $1 (string): Directory to test

Exit codes

  • 0: Present; 1 Not present

sys_path_prepend

Prepend a directory to PATH if it is not already present.

Arguments

  • $1 (string): Directory to prepend

Exit codes

  • 0: Always

sys_path_append

Append a directory to PATH if it is not already present.

Arguments

  • $1 (string): Directory to append

Exit codes

  • 0: Always

sys_path_remove

Remove all occurrences of a directory from PATH.

Arguments

  • $1 (string): Directory to remove

Exit codes

  • 0: Always

sys_path_dedup

Deduplicate PATH entries, preserving first-occurrence order.

Exit codes

  • 0: Always

sys_path_print

Print each directory in PATH on its own line.

Example

sys_path_print | grep '/usr/local'

Exit codes

  • 0: Always

Output on stdout

  • One directory per line

sys_path_derecurse

Remove the directory containing the current script from PATH to prevent infinite recursion when a script shadows a system command.

Exit codes

  • 0: Always