diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-09-26 12:45:01 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-09-26 12:45:01 +1300 |
commit | eb32901feddce045f359c5bd2d59ade9aaf467ee (patch) | |
tree | b64f17f2b63fed8aee41fad65c5e08a86dc451ab | |
parent | Update submodules (diff) | |
download | dotfiles-eb32901feddce045f359c5bd2d59ade9aaf467ee.tar.gz dotfiles-eb32901feddce045f359c5bd2d59ade9aaf467ee.zip |
Use simpler method for `path check`
Easier to read and does not require a subshell
-rw-r--r-- | sh/shrc.d/path.sh | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh index a5940dd7..2513b0e5 100644 --- a/sh/shrc.d/path.sh +++ b/sh/shrc.d/path.sh @@ -58,11 +58,12 @@ path() { ;; # Check whether a directory is in PATH - check) ( - # shellcheck disable=SC2030 - path=:$PATH: - [ "$path" != "${path%:"$2":*}" ] - ) ;; + check) + case :$PATH: in + *:"$2":*) return 0 ;; + esac + return 1 + ;; # Print help output (also done if command not found) help) |