2013-04-01 17:49:02 +00:00
|
|
|
function __fish_not_contain_opt -d "Checks that a specific option is not in the current command line"
|
2016-11-28 05:27:22 +00:00
|
|
|
set -l next_short
|
|
|
|
set -l short_opt
|
|
|
|
set -l long_opt
|
|
|
|
|
|
|
|
for i in $argv
|
2017-04-14 06:13:55 +00:00
|
|
|
if test -n "$next_short"
|
2016-11-28 05:27:22 +00:00
|
|
|
set next_short
|
|
|
|
set short_opt $short_opt $i
|
|
|
|
else
|
|
|
|
switch $i
|
|
|
|
case -s
|
|
|
|
set next_short 1
|
|
|
|
case '-*'
|
2017-06-09 19:12:36 +00:00
|
|
|
echo __fish_not_contain_opt: Unknown option $i >&2
|
2016-11-28 05:27:22 +00:00
|
|
|
return 1
|
|
|
|
|
2017-04-14 06:13:55 +00:00
|
|
|
case '*'
|
2016-11-28 05:27:22 +00:00
|
|
|
set long_opt $long_opt $i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for i in $short_opt
|
2017-04-14 06:13:55 +00:00
|
|
|
if test -z "$i"
|
2016-11-28 05:27:22 +00:00
|
|
|
continue
|
|
|
|
end
|
|
|
|
|
2024-01-22 06:42:45 +00:00
|
|
|
if string match -qr -- "^-$i|^-[^-]*$i" (commandline -cpx)
|
2016-11-28 05:27:22 +00:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2017-04-14 06:13:55 +00:00
|
|
|
if string match -qr -- "^-$i|^-[^-]*$i" (commandline -ct)
|
2016-11-28 05:27:22 +00:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for i in $long_opt
|
2017-04-14 06:13:55 +00:00
|
|
|
if test -z "$i"
|
2016-11-28 05:27:22 +00:00
|
|
|
continue
|
|
|
|
end
|
|
|
|
|
2024-01-22 06:42:45 +00:00
|
|
|
if contains -- --$i (commandline -cpx)
|
2016-11-28 05:27:22 +00:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return 0
|
2007-12-17 23:03:15 +00:00
|
|
|
end
|