From cd7b34f27453b222c9b9fd26c14d56f7c88a3643 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 2 Jan 2017 16:00:15 +1300 Subject: Handle simple relative dirs in md() And add an issue about handling complex ones --- sh/shrc.d/md.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sh') 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' -- cgit v1.2.3