aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/path.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-11 14:52:11 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-11 14:52:11 +1300
commit6e8c6c521ae5d60427634be01b82fe61a79f192b (patch)
tree5349fc3e9838c69dbb6fd69f0234ea921ea446ea /sh/shrc.d/path.sh
parentFactor out zsh ENV hack into one file (diff)
downloaddotfiles-6e8c6c521ae5d60427634be01b82fe61a79f192b.tar.gz
dotfiles-6e8c6c521ae5d60427634be01b82fe61a79f192b.zip
Refactor some conditionals
Diffstat (limited to 'sh/shrc.d/path.sh')
-rw-r--r--sh/shrc.d/path.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh
index 70947515..a854e148 100644
--- a/sh/shrc.d/path.sh
+++ b/sh/shrc.d/path.sh
@@ -34,7 +34,9 @@ path() {
# Add a directory at the start of $PATH
insert)
- [ "$#" -eq 2 ] || set -- "$1" "$PWD"
+ if ! [ "$#" -eq 2 ] ; then
+ set -- "$1" "$PWD"
+ fi
path _argcheck "$@" || return
if path check "$2" ; then
printf >&2 'path(): %s: %s already in PATH\n' "$@"
@@ -45,7 +47,9 @@ path() {
# Add a directory to the end of $PATH
append)
- [ "$#" -eq 2 ] || set -- "$1" "$PWD"
+ if ! [ "$#" -eq 2 ] ; then
+ set -- "$1" "$PWD"
+ fi
path _argcheck "$@" || return
if path check "$2" ; then
printf >&2 'path(): %s: %s already in PATH\n' "$@"
@@ -56,7 +60,9 @@ path() {
# Remove a directory from $PATH
remove)
- [ "$#" -eq 2 ] || set -- "$1" "$PWD"
+ if ! [ "$#" -eq 2 ] ; then
+ set -- "$1" "$PWD"
+ fi
path _argcheck "$@" || return
if ! path check "$2" ; then
printf >&2 'path(): %s: %s not in PATH\n' "$@"
@@ -108,7 +114,9 @@ path() {
# Check whether a directory is in PATH
check)
path _argcheck "$@" || return
- [ "$#" -eq 2 ] || set -- "$1" "$PWD"
+ if ! [ "$#" -eq 2 ] ; then
+ set -- "$1" "$PWD"
+ fi
case :$PATH: in
*:"$2":*) return 0 ;;
esac