From eb32901feddce045f359c5bd2d59ade9aaf467ee Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 26 Sep 2016 12:45:01 +1300 Subject: Use simpler method for `path check` Easier to read and does not require a subshell --- sh/shrc.d/path.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sh/shrc.d/path.sh') 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) -- cgit v1.2.3