From 9ed69d70d9201817c7f36c7f210ce163e84eb54b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 00:39:02 +1200 Subject: Reimplement sd() without subshell --- sh/shrc.d/bd.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sh/shrc.d/bd.sh') 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 -- cgit v1.2.3