Created
December 26, 2019 23:33
-
-
Save deseven/141d8f1b2323d4114e278ffe6ecfc096 to your computer and use it in GitHub Desktop.
removes dupes from fish variable (taken from fish issue #296)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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