Created
June 28, 2015 23:49
-
-
Save michaelmrose/112611102c201fb965a3 to your computer and use it in GitHub Desktop.
default variables and variable parsing in fish
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
set somevariable default val | |
set someothervariable default val | |
for i in (getvariables $argv) | |
set val (explode $i) | |
set $val[1] $val[2] | |
end | |
function getvariables | |
if not substr "$argv" = | |
return 1 | |
else | |
set vars (println $argv | grep =) | |
for i in $vars | |
echo (echo $i | cut -d "=" -f1) (echo $i | cut -d "=" -f2) | |
end | |
end | |
end | |
function explode | |
echo $argv | sed 's/ /\n/g' | |
end | |
function substr | |
set e1 (tolower $argv[1]) | |
set e2 (tolower $argv[2]) | |
expr match $e1 .\*$e2.\* > /dev/null | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment