diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-20 17:31:28 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-20 17:31:28 +1200 |
commit | a3d0e2dc7aa4d210aad7273346bd2fcee77d63ef (patch) | |
tree | 41869240b425ace7660053c7f2c252e15e55b2e8 /sh/shrc.d/path.sh | |
parent | Port path() to POSIX sh (diff) | |
download | dotfiles-a3d0e2dc7aa4d210aad7273346bd2fcee77d63ef.tar.gz dotfiles-a3d0e2dc7aa4d210aad7273346bd2fcee77d63ef.zip |
Dance for shellcheck in path()
Diffstat (limited to 'sh/shrc.d/path.sh')
-rw-r--r-- | sh/shrc.d/path.sh | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh index 22374310..abeb5962 100644 --- a/sh/shrc.d/path.sh +++ b/sh/shrc.d/path.sh @@ -12,8 +12,9 @@ path() { # Check first argument to figure out operation case $1 in - # List current directories in $PATH + # List current directories in PATH list|'') ( + # shellcheck disable=SC2030 path=$PATH: while [ -n "$path" ] ; do dir=${path%%:*} @@ -26,7 +27,7 @@ path() { # Add a directory at the start of $PATH insert) if path check "$2" ; then - printf >&2 'path(): %s already in $PATH\n' + printf >&2 'path(): %s already in PATH\n' return 1 fi PATH=${2}${PATH:+:"$PATH"} @@ -35,7 +36,7 @@ path() { # Add a directory to the end of $PATH append) if path check "$2" ; then - printf >&2 'path(): %s already in $PATH\n' + printf >&2 'path(): %s already in PATH\n' return 1 fi PATH=${PATH:+"$PATH":}${2} @@ -44,10 +45,11 @@ path() { # Remove a directory from $PATH remove) if ! path check "$2" ; then - printf >&2 'path(): %s not in $PATH\n' + printf >&2 'path(): %s not in PATH\n' return 1 fi PATH=$( + # shellcheck disable=SC2031 path=:$path: path=${path%%:"$2":*}:${path#*:"$2":} path=${path#:} @@ -56,8 +58,9 @@ path() { ) ;; - # Check whether a directory is in $PATH + # Check whether a directory is in PATH check) ( + # shellcheck disable=SC2030 path=:$PATH: [ "$path" != "${path%:"$2":*}" ] ) ;; |