aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ISSUES.markdown2
-rw-r--r--sh/shrc.d/md.sh9
2 files changed, 11 insertions, 0 deletions
diff --git a/ISSUES.markdown b/ISSUES.markdown
index dda99334..0b31661f 100644
--- a/ISSUES.markdown
+++ b/ISSUES.markdown
@@ -17,3 +17,5 @@ Known issues
jobspecs around that flee after a jobs builtin run; only saw this manifest
after 90dcadf; either I understand job specs really poorly or this may be a
bug in bash
+* md() does not handle e.g. "../..". If there's a tidy way of making it do so
+ that would probably be worhwhile.
diff --git a/sh/shrc.d/md.sh b/sh/shrc.d/md.sh
index cf44abb3..1f8a8aaf 100644
--- a/sh/shrc.d/md.sh
+++ b/sh/shrc.d/md.sh
@@ -10,6 +10,15 @@ md() {
# If first arg unset or empty, assume the user means the current dir
[ -n "$1" ] || set -- "$PWD"
+ # If specified path is . or .., quietly expand it
+ case $1 in
+ .) set -- "${PWD%/}" ;;
+ ..)
+ set -- "${PWD%/}"
+ set -- "${1%/*}"
+ ;;
+ esac
+
# If specified path not a directory, refuse to mark it
if ! [ -d "$1" ] ; then
printf >&2 'md(): Not a directory\n'