Re:Justpath to explore PATH environment variable quickly
by throwaway84846 on Sunday February 25, 2024 @09:52PM
(#39507169)
I use 'path=( ${(u)^path:A}(N-/) )' instead of that for loop
[ Parent
| on HN ]
Re:Justpath to explore PATH environment variable quickly
by mst on Monday February 26, 2024 @08:09AM
(#39510865)
To just reduce the current entries to those that exist, I'd probably do
PATH=$(perl -e 'print join ":", grep -d, split ":", $ENV{PATH}')
but that's because as a 20 year perl hacker and thus connoiseur of line noise, I'd rather read that than the shell clever.(this doesn't mean the shell clever is bad, it just means I don't find -that- dialect of line noise as skimmable)
Re:Justpath to explore PATH environment variable quickly
by JNRowe on Monday February 26, 2024 @05:35PM
(#39517572)
General point about comfort noted, but they don't do the same thing.
$^path(N) is an equivalent to your perl expression. The snippet throwaway84846 posted also removes duplicates and collapses symlinks from /usr-merge for example.