ambevar-dotfiles/.local/bin/echopath

29 lines
373 B
Plaintext
Raw Normal View History

2013-11-14 12:32:09 +01:00
#!/bin/sh
if [ "$1" = "-h" ]; then
cat <<EOF>&2
2013-11-14 12:32:09 +01:00
Usage: ${0##*/} PATH
Display PATH one entry per line. If PATH is not provided, use \$PATH by default.
2013-11-14 12:32:09 +01:00
EOF
exit
2013-11-14 12:32:09 +01:00
fi
if [ $# -ne 0 ]; then
ARG="$1"
2013-11-14 12:32:09 +01:00
else
ARG="$PATH"
2013-11-14 12:32:09 +01:00
fi
case "$ARG" in
*:*) SEP=':';;
*\;*) SEP=';';;
*/*) SEP='/';;
*,*) SEP=',';;
*\|*) SEP='|';;
*) SEP=':';;
esac
echo "$ARG" | awk -v RS=$SEP '1'