feature request: commands to easily manipulate $PATH
Bug #619010 reported by
Lesmana Zimmer
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: bash
adding directories to $PATH is a very common task. it is desirable to only add a directory to $PATH if it is not already there. sadly that is quite hard to do. removing directories from $PATH is not as common but at least as hard.
i think bash should have commands to add directories uniquely to $PATH and remove from $PATH
for example:
path_append () { path_remove $1; export PATH="$PATH:$1"; }
path_prepend () { path_remove $1; export PATH="$1:$PATH"; }
path_remove () { export PATH=`echo -n $PATH | awk -v RS=: -v ORS=: '$0 != "'$1'"' | sed 's/:$//'`; }
it would be better if the commands do not depend on anything outside of bash
To post a comment you must log in.