echopath 373 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. if [ "$1" = "-h" ]; then
  3. cat <<EOF>&2
  4. Usage: ${0##*/} PATH
  5. Display PATH one entry per line. If PATH is not provided, use \$PATH by default.
  6. EOF
  7. exit
  8. fi
  9. if [ $# -ne 0 ]; then
  10. ARG="$1"
  11. else
  12. ARG="$PATH"
  13. fi
  14. case "$ARG" in
  15. *:*) SEP=':';;
  16. *\;*) SEP=';';;
  17. */*) SEP='/';;
  18. *,*) SEP=',';;
  19. *\|*) SEP='|';;
  20. *) SEP=':';;
  21. esac
  22. echo "$ARG" | awk -v RS=$SEP '1'