aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-11 13:25:46 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-11 13:25:46 +1300
commita270b086c552f24a01c9eb6009c9c610abea5f80 (patch)
tree3d62066b18b32914c4671bf9f95ea4983812e2eb /sh
parentCorrect completion for deep pass(1) directories (diff)
downloaddotfiles-a270b086c552f24a01c9eb6009c9c610abea5f80.tar.gz
dotfiles-a270b086c552f24a01c9eb6009c9c610abea5f80.zip
Refactor "path list" not to require a subshell
Diffstat (limited to 'sh')
-rw-r--r--sh/shrc.d/path.sh17
1 files changed, 9 insertions, 8 deletions
diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh
index b6b1820f..70947515 100644
--- a/sh/shrc.d/path.sh
+++ b/sh/shrc.d/path.sh
@@ -5,15 +5,16 @@ path() {
case $1 in
# List current directories in PATH
- list|'') (
- path=$PATH:
- while [ -n "$path" ] ; do
- dir=${path%%:*}
- path=${path#*:}
- [ -n "$dir" ] || continue
- printf '%s\n' "$dir"
+ list|'')
+ set -- "$PATH":
+ while [ -n "$1" ] ; do
+ case $1 in
+ :*) ;;
+ *) printf '%s\n' "${1%%:*}" ;;
+ esac
+ set -- "${1#*:}"
done
- ) ;;
+ ;;
# Helper function checks directory argument makes sense
_argcheck)