Guest User

Untitled

a guest
Nov 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. set -f path=("/new/entry" $path:q)
  2.  
  3. set -f path=('/new/'e"ntry" $path:q)
  4.  
  5. set -f path=(/'new/entry' $path:q)
  6.  
  7. set path=(/new/entry $path:q)
  8. set -f path=($path:q)
  9.  
  10. if ( $PATH =~ */some/path* ) then
  11. set PATH = ($PATH:/some/path)
  12. endif
  13.  
  14. UNIQUE_LIST=$( echo "$PATH" | tr ':' 'n' | sort | uniq)
  15.  
  16. # then we place in front those from UNIQUELIST that match an ordered list
  17. # note that that way, those who didn't have "/sbin" still won't have it, but if they did
  18. # it will be at the right place in the list
  19. shouldbefirst="/bin /sbin /usr/bin" # complete or re-order as needed on your system...
  20. for dir in $shouldbefirst
  21. do
  22. if ( echo "$UNIQUE_LIST" | grep "$dir" >/dev/null 2>/dev/null)
  23. then #we have this dir in UNIQUE_LIST
  24. NEWLIST="${NEWLIST}:${dir}"
  25. UNIQUE_LIST="$( echo "$UNIQUE_LIST" | grep -v "^$dir$")" #we treated that one, take it out of the original list
  26. fi
  27. done
  28.  
  29. # then put the remaining of UNIQUE_LIST in the order you want (here, alphabetically)
  30. for dir in $UNIQUE_LIST
  31. do
  32. NEWLIST="${NEWLIST}:${dir}"
  33. UNIQUE_LIST="$( echo "$UNIQUE_LIST" | grep -v "^$dir$")" #we treated that one, take it out of the original list
  34. done
  35.  
  36. # get rid of possible first ":" (as NEWLIST starts empty)
  37. NEWLIST="$(echo "$NEWLIST" | sed -e 's/^://')"
  38.  
  39. # and then : (I test by placing "echo" in front, get rid of "echo" if it looks fine)
  40. echo PATH="$NEWLIST"
Add Comment
Please, Sign In to add comment