aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/bd.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-05-26 00:39:02 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-05-26 00:39:02 +1200
commit9ed69d70d9201817c7f36c7f210ce163e84eb54b (patch)
treead2a9838bdb36e5492858d19d2d056534f109a3d /sh/shrc.d/bd.sh
parentEven terser/nicer bd() (diff)
downloaddotfiles-9ed69d70d9201817c7f36c7f210ce163e84eb54b.tar.gz
dotfiles-9ed69d70d9201817c7f36c7f210ce163e84eb54b.zip
Reimplement sd() without subshell
Diffstat (limited to 'sh/shrc.d/bd.sh')
-rw-r--r--sh/shrc.d/bd.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh
index 5b2c3d59..2dc21173 100644
--- a/sh/shrc.d/bd.sh
+++ b/sh/shrc.d/bd.sh
@@ -7,8 +7,8 @@ bd() {
return 2
fi
- # Look at argument given
- case $1 in
+ # Look at argument given; default to going up one level
+ case ${1:-..} in
# If it has a leading slash or is . or .., don't touch the arguments
/*|.|..) ;;
@@ -18,7 +18,7 @@ bd() {
*)
# Push the current directory onto the stack
- set -- "$1" "$PWD"
+ set -- "${1%/}" "$PWD"
# Keep chopping at the current directory until it's empty or it
# matches the request