Fish: remove path from $PATH fails if $PATH edited with sed -


i'm using fish 2.2.0. (yes, know it's old, cannot it.)

i want unset path (/usr/local/ferret-6.82/bin) $path. assume using sed work:

> echo $path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /usr/local/ferret-6.82/bin /opt/intel/bin  > echo $path | sed -e 's:/usr/local/ferret-6.82/bin ::g' /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /opt/intel/bin 

great! however...

> set -gx path (echo $path | sed -e 's:/usr/local/ferret-6.82/bin ::g') set: warning: path component /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /opt/intel/bin may not valid in path. set: no such file or directory > echo $path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /usr/local/ferret-6.82/bin /opt/intel/bin 

of course directories exist. setting path manually works:

> set -gx path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /opt/intel/bin > echo $path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /opt/intel/bin 

what wrong here? why path setting sed fail?

$path, $cdpath , $manpath special in fish. (since 2.2.0, specific variables. before that, apply variable)

they lists 1 element per component converted , usual colon-delimited form when exporting , importing external programs.

what want here either use fish-script:

if set -l ind (contains -i -- /usr/local/ferret-6.82/bin $path)     set -e path[$ind] end 

the contains -i return 0 , output index first argument at, set -e remove element list. "--" option-separator, after no argument interpreted option. note missing quotes $path, result in each component of $path being passed separate argument.

or, since fish splits command substitutions on newlines, can operate on $path per-line, with

printf '%s\n' $path | sed '\_/usr/local/ferret-6.82/bin_d' 

(note: "d" command, necessary escape delimiter - "_" in case - on first use if it's not "/")


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -