A collection of scripts and configurations for Bash (and others)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. function in_envpath()
  3. {
  4. for path in $(sed 's/:/\n/g' <<< $PATH)
  5. do
  6. if [ $path = $1 ]; then
  7. return 0 # 0 = success!
  8. fi
  9. done
  10. return 1 # non-zero = failure
  11. }
  12. function add_to_envpath()
  13. {
  14. if in_envpath $1; then
  15. return 0 # Success! Path is already IN $PATH
  16. fi
  17. if [ -d "$1" ]; then
  18. PATH="$PATH:$1"
  19. fi
  20. }