aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-05-26 17:48:49 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-05-26 17:48:49 +1200
commitcd114eec94fd07e831ef6c70b7732408d0a59e90 (patch)
tree6dadb976a2a03fa4db4a5ef36c1a209b2152a6d7 /sh
parent9ed69d70d9201817c7f36c7f210ce163e84eb54b (diff)
downloaddotfiles-cd114eec94fd07e831ef6c70b7732408d0a59e90.tar.gz
Correct default behaviour for bd() with no args
Diffstat (limited to 'sh')
-rw-r--r--sh/shrc.d/bd.sh15
1 files changed, 9 insertions, 6 deletions
diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh
index 2dc21173..7901e115 100644
--- a/sh/shrc.d/bd.sh
+++ b/sh/shrc.d/bd.sh
@@ -1,14 +1,17 @@
# Move back up the directory tree to the first directory matching the name
bd() {
- # Check argument count
- if [ "$#" -gt 1 ] ; then
- printf >&2 'bd(): Too many arguments\n'
- return 2
- fi
+ # Check argument count; default to ".."
+ case $# in
+ 0) set -- .. ;;
+ 1) ;;
+ *)
+ printf >&2 'bd(): Too many arguments\n'
+ return 2
+ esac
# Look at argument given; default to going up one level
- case ${1:-..} in
+ case $1 in
# If it has a leading slash or is . or .., don't touch the arguments
/*|.|..) ;;