removes dupes from fish variable (taken from fish issue #296)
function varclear --description 'Remove duplicates from environment variable' | |
if test (count $argv) = 1 | |
set -l newvar | |
set -l count 0 | |
for v in $$argv | |
if contains -- $v $newvar | |
set count (math $count+1) | |
else | |
set newvar $newvar $v | |
end | |
end | |
set $argv $newvar | |
test $count -gt 0 | |
and echo Removed $count duplicates from $argv | |
else | |
for a in $argv | |
varclear $a | |
end | |
end | |
return 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment