blob: a71349313fe1e6b7e2db1e327512b1775fb48809 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# Set marked directory to given dir or current dir
md() {
# Accept up to one argument
if [ "$#" -gt 1 ] ; then
printf >&2 'md(): Too many arguments\n'
return 2
fi
# 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
[ -n "$1" ] || return
# Save the specified path in the marked directory var
# shellcheck disable=SC2034
PMD=$1
}
|