logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

dirname.t (435B)


  1. #!/bin/sh
  2. failed=0
  3. path=../bin/dirname
  4. status() {
  5. if [ "$2" -eq 0 ]; then
  6. echo "OK: ${1}"
  7. else
  8. echo "FAILED: ${1}"
  9. failed=1
  10. fi
  11. }
  12. [ "$(${path} 2>/dev/null)" = "" ] ; status "no args" $?
  13. [ "$(${path} /usr/bin)" = "/usr" ] ; status "/usr/bin" $?
  14. [ "$(${path} /usr//bin)" = "/usr" ] ; status "/usr//bin" $?
  15. ## POSIX-tests
  16. #[ "$(${path} //)" = "//" ] ; status "//" $?
  17. #[ "$(${path} ///)" = "///" ] ; status "///" $?
  18. exit $failed