mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 16:41:41 +08:00
11a60c8374
I hate doing this but I am tired of touching a fish script as part of some change and having `make style` radically change it. Which makes editing fish scripts more painful than it needs to be. It is time to do a wholesale reformatting of these scripts to conform to the documented style as implemented by the `fish_indent` program.
54 lines
1.1 KiB
Fish
54 lines
1.1 KiB
Fish
|
|
function __fish_contains_opt -d "Checks if a specific option has been given in the current commandline"
|
|
set -l next_short
|
|
|
|
set -l short_opt
|
|
set -l long_opt
|
|
|
|
for i in $argv
|
|
if test $next_short
|
|
set next_short
|
|
set short_opt $short_opt $i
|
|
else
|
|
switch $i
|
|
case -s
|
|
set next_short 1
|
|
case '-*'
|
|
echo __fish_contains_opt: Unknown option $i
|
|
return 1
|
|
|
|
case '**'
|
|
set long_opt $long_opt $i
|
|
end
|
|
end
|
|
end
|
|
|
|
for i in $short_opt
|
|
|
|
if test -z $i
|
|
continue
|
|
end
|
|
|
|
if commandline -cpo | __fish_sgrep -- "^-"$i"\|^-[^-]*"$i >/dev/null
|
|
return 0
|
|
end
|
|
|
|
if commandline -ct | __fish_sgrep -- "^-"$i"\|^-[^-]*"$i >/dev/null
|
|
return 0
|
|
end
|
|
end
|
|
|
|
for i in $long_opt
|
|
if test -z $i
|
|
continue
|
|
end
|
|
|
|
if contains -- --$i (commandline -cpo)
|
|
return 0
|
|
end
|
|
end
|
|
|
|
return 1
|
|
end
|
|
|