I’m trying to remove all directories whose path matches a certain pattern from the path, within a script that would be sourced using .
. The following one-line perl invocation seems idiomatic, but it prints a warning “Substitution replacement not terminated at -e line 1.
” when the script is sourced:
PATH=`perl -e 'print join q{:},grep !m{/node-},split(m{[:]},$ENV{"PATH"})'`
But the warning doesn’t appear when I enter that one line into bash interactively!
Perl 5.32.1.
(And it seems like I should be able to accomplish the same goal with a shell builtin,
PATH=${PATH%%/opt/node-*/bin:}
but that leaves the path unchanged.)