fork/fish-shell

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

Johannes AltmanningerMark private functions that don't need localizationa53db7256

master
1.1 KiB42 linesraw
1# localization: skip(private)
2function __fish_seen_argument --description 'Check whether argument is used'
3    argparse --move-unknown 's/short=+&' 'o/old=+&' 'l/long=+&' 'w/windows=+&' -- $argv
4
5    set --local tokens (commandline --current-process --tokens-expanded --cut-at-cursor)
6    set --erase tokens[1]
7
8    for t in $tokens
9        for s in $_flag_s
10            if string match --regex --quiet -- "^-[A-z0-9]*"$s"[A-z0-9]*\$" $t
11                return 0
12            end
13        end
14
15        for o in $_flag_o
16            if string match --quiet -- "-$o" $t
17                return 0
18            end
19        end
20
21        for l in $_flag_l
22            # Make sure to only prefix-match --foo=bar style tokens
23            if string match --quiet -- "--$l" (string replace -r -- '^(--.*?)=.*' '$1' $t)
24                return 0
25            end
26        end
27
28        for w in $_flag_w
29            if string match --quiet -- "/$w" $t
30                return 0
31            end
32        end
33
34        for raw_arg in $argv_opts $argv
35            if string match --quiet -- $t $raw_arg
36                return 0
37            end
38        end
39    end
40
41    return 1
42end