Skip to content

Commit b9976d6

Browse files
RocketMaDevMic92
authored andcommitted
switch to zsh grammar
1 parent 513630d commit b9976d6

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

completions/zsh/_patchelf

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
#compdef patchelf
22

3-
function _get_dep() {
4-
if [ -f $words[2] ] && [[ $words[2] =~ [^.]+ ]]; then # check if arg #1 is a elf file and not a so
5-
deps=($(patchelf --print-needed $words[2] 2>/dev/null)) # discard error
6-
if [ $? -ne 0 ] || [ ${#deps[*]} -eq 0 ]; then # if no dependency or not a elf
7-
_files # fallback to _files
8-
else
9-
_values "LIBS" ${deps[*]} # else use dependencies of the file as candidates
10-
fi
11-
elif [ -f $words[-1] ] && [[ $words[-1] =~ [^.]+ ]]; then # check arg #-1, as most people do like this
12-
deps=($(patchelf --print-needed $words[-1] 2>/dev/null))
13-
if [ $? -ne 0 ] || [ ${#deps[*]} -eq 0 ]; then
3+
_get_dep() {
4+
# preparm have fewer checks, as they can't be the so to replace
5+
if [[ -f $words[2] ]] { # check if arg #1 is a elf file and not a so
6+
local deps=($(patchelf --print-needed $words[2] 2>/dev/null)) # discard error
7+
if [[ $? -ne 0 ]] || [[ $#deps -eq 0 ]] { # if no dependency or not a elf
8+
_files # fallback to _files
9+
} else {
10+
_values "LIBS" $deps # else use dependencies of the file as candidates
11+
}
12+
# postparm need to check
13+
} elif [[ -f $words[-1] ]] && [[ -z ${words[-1]:e} ]] { # check arg #-1, as most people do like this
14+
local deps=($(patchelf --print-needed $words[-1] 2>/dev/null))
15+
if [[ $? -ne 0 ]] || [[ $#deps -eq 0 ]] {
1416
_files
15-
else
16-
_values "LIBS" ${deps[*]}
17-
fi
18-
else
17+
} else {
18+
_values "LIBS" $deps
19+
}
20+
} else {
1921
_files
20-
fi
22+
}
2123
}
2224

2325
local options=(

0 commit comments

Comments
 (0)