fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerMark private functions that don't need localizationa53db7256

master
1.1 KiB50 linesraw
1# localization: skip(private)
2function __fish_not_contain_opt -d "Checks that a specific option is not in the current command line"
3    set -l next_short
4    set -l short_opt
5    set -l long_opt
6
7    for i in $argv
8        if test -n "$next_short"
9            set next_short
10            set short_opt $short_opt $i
11        else
12            switch $i
13                case -s
14                    set next_short 1
15                case '-*'
16                    echo __fish_not_contain_opt: Unknown option $i >&2
17                    return 1
18
19                case '*'
20                    set long_opt $long_opt $i
21            end
22        end
23    end
24
25    for i in $short_opt
26        if test -z "$i"
27            continue
28        end
29
30        if string match -qr -- "^-$i|^-[^-]*$i" (commandline -cpx)
31            return 1
32        end
33
34        if string match -qr -- "^-$i|^-[^-]*$i" (commandline -ct)
35            return 1
36        end
37    end
38
39    for i in $long_opt
40        if test -z "$i"
41            continue
42        end
43
44        if contains -- --$i (commandline -cpx)
45            return 1
46        end
47    end
48
49    return 0
50end