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