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