aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-05-25 18:31:36 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-05-25 18:31:36 +1200
commite199448d724746af892a67608c88fb2ddc075c72 (patch)
tree66761d9b5414add75cb851cce40c77e1379bbfb7 /sh/shrc.d
parentShorter/saner implementation for bd() (diff)
downloaddotfiles-e199448d724746af892a67608c88fb2ddc075c72.tar.gz
dotfiles-e199448d724746af892a67608c88fb2ddc075c72.zip
Even terser/nicer bd()
Diffstat (limited to 'sh/shrc.d')
-rw-r--r--sh/shrc.d/bd.sh14
1 files changed, 7 insertions, 7 deletions
diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh
index 02da6773..5b2c3d59 100644
--- a/sh/shrc.d/bd.sh
+++ b/sh/shrc.d/bd.sh
@@ -22,18 +22,18 @@ bd() {
# Keep chopping at the current directory until it's empty or it
# matches the request
- while [ -n "$2" ] ; do
- set -- "$1" "${2%/*}"
+ while set -- "$1" "${2%/*}" ; do
case $2 in
- (*/"$1") break ;;
+ */"$1") break ;;
+ */*) ;;
+ *)
+ printf >&2 'bd(): No match\n'
+ return 1
+ ;;
esac
done
# If the first argument ended up empty, we have no match
- if [ -z "$2" ] ; then
- printf >&2 'bd(): No match\n'
- return 1
- fi
shift
;;
esac