aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-08 02:05:16 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-08 02:05:16 +1300
commit8e20116f74753fa07d2f15b915aa5a700fd1f53c (patch)
treeb1bffae1715453286eddb25587d92ce84559f65c /sh
parentRemove misplaced \0 in completion func (diff)
downloaddotfiles-8e20116f74753fa07d2f15b915aa5a700fd1f53c.tar.gz
dotfiles-8e20116f74753fa07d2f15b915aa5a700fd1f53c.zip
Adjust subshell logic in md()
Diffstat (limited to 'sh')
-rw-r--r--sh/shrc.d/md.sh13
1 files changed, 8 insertions, 5 deletions
diff --git a/sh/shrc.d/md.sh b/sh/shrc.d/md.sh
index 6fd3d7ca..a7134931 100644
--- a/sh/shrc.d/md.sh
+++ b/sh/shrc.d/md.sh
@@ -7,11 +7,14 @@ md() {
return 2
fi
- # If first arg unset or empty, assume the user means the current dir
- [ -n "$1" ] || set -- "$PWD"
-
- # Jump to the dir and emit PWD from a subshell to get an absolute path
- set -- "$(cd -- "$1" && printf %s "$PWD")"
+ # If argument given, change to it in subshell to get absolute path.
+ # If not, use current working directory.
+ if [ -n "$1" ] ; then
+ set -- "$(cd -- "$1" && printf '%s/' "$PWD")"
+ set -- "${1%%/}"
+ else
+ set -- "$PWD"
+ fi
# If that turned up empty, we have failed; the cd call probably threw an
# error for us too