A collection of scripts and configurations for Bash (and others)
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

26 行
351B

  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. }