summaryrefslogtreecommitdiff
path: root/completions/tshark
diff options
context:
space:
mode:
Diffstat (limited to 'completions/tshark')
-rw-r--r--completions/tshark80
1 files changed, 39 insertions, 41 deletions
diff --git a/completions/tshark b/completions/tshark
index 2f18d0a3..396fbcbd 100644
--- a/completions/tshark
+++ b/completions/tshark
@@ -23,13 +23,13 @@ _tshark()
cur=${cur#*:}
_filedir
else
- [ -n "$_tshark_prefs" ] ||
- _tshark_prefs="$("$1" -G defaultprefs 2>/dev/null | command\
- sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' |
+ [[ -v _tshark_prefs ]] ||
+ _tshark_prefs="$("$1" -G defaultprefs 2>/dev/null | command sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' |
tr '\n' ' ')"
- COMPREPLY=( $(compgen -P "$prefix" -W "$_tshark_prefs" \
- -- "${cur:${#prefix}}") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
+ : ${prefix:=}
+ COMPREPLY=($(compgen -P "$prefix" -W "$_tshark_prefs" \
+ -- "${cur:${#prefix}}"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
fi
return
;;
@@ -37,73 +37,71 @@ _tshark()
return
;;
-*i)
- COMPREPLY=( $(compgen -W \
- "$("$1" -D 2>/dev/null | awk '{print $2}')" -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ "$("$1" -D 2>/dev/null | awk '{print $2}')" -- "$cur"))
return
;;
-*y)
local opts i
- for (( i=${#words[@]}-1; i > 0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -i ]]; then
- opts+="-i ${words[i+1]}"
+ opts+="-i ${words[i + 1]}"
break
fi
done
- COMPREPLY=( $(compgen -W "$("$1" $opts -L 2>/dev/null | \
- awk '/^ / { print $1 }')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$("$1" $opts -L 2>/dev/null |
+ awk '/^ / { print $1 }')" -- "$cur"))
return
;;
-*[ab])
- COMPREPLY=( $(compgen -W 'duration: filesize: files:' -- "$cur") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W 'duration: filesize: files:' -- "$cur"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
return
;;
- -*r)
- _filedir '@(pcap?(ng)|cap)?(.gz)'
- return
- ;;
- -*H)
+ -*[rH])
+ # -r accepts a lot of different file types
_filedir
return
;;
-*w)
_filedir
- [[ $cur == @(|-) ]] && COMPREPLY+=( - )
+ [[ $cur == @(|-) ]] && COMPREPLY+=(-)
return
;;
-*F)
- COMPREPLY=( $(compgen -W "$("$1" -F 2>&1 | \
- awk '/^ / { print $1 }')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$("$1" -F 2>&1 |
+ awk '/^ / { print $1 }')" -- "$cur"))
return
;;
-*O)
- local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*},"
- [ -n "$_tshark_protocols" ] ||
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ [[ -v _tshark_protocols ]] ||
_tshark_protocols="$("$1" -G protocols 2>/dev/null |
cut -f 3 | tr '\n' ' ')"
- COMPREPLY=( $(compgen -W "$_tshark_protocols" -- "${cur##*,}") )
- [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} )
+ COMPREPLY=($(compgen -W "$_tshark_protocols" -- "${cur##*,}"))
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
-*T)
# Parse from: tshark -T . 2>&1 | awk -F \" '/^\t*"/ { print $2 }'
- COMPREPLY=( $(compgen -W \
- 'pdml ps psml json jsonraw ek tabs text fields' -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ 'pdml ps psml json jsonraw ek tabs text fields' -- "$cur"))
return
;;
-*t)
# Parse from: tshark -t . 2>&1 | awk -F \" '/^\t*"/ { print $2 }'
- COMPREPLY=( $(compgen -W \
- 'a ad adoy d dd e r u ud udoy' -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ 'a ad adoy d dd e r u ud udoy' -- "$cur"))
return
;;
-*u)
# TODO: could be parsed from "-u ." output
- COMPREPLY=( $(compgen -W 's hms' -- "$cur") )
+ COMPREPLY=($(compgen -W 's hms' -- "$cur"))
return
;;
-*W)
- COMPREPLY=( $(compgen -W 'n' -- "$cur") )
+ COMPREPLY=($(compgen -W 'n' -- "$cur"))
return
;;
-*X)
@@ -111,28 +109,28 @@ _tshark()
cur=${cur#*:}
_filedir lua
else
- COMPREPLY=( $(compgen -P "$prefix" -W 'lua_script:' -- \
- "${cur:${#prefix}}") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
+ COMPREPLY=($(compgen -P "$prefix" -W 'lua_script:' -- \
+ "${cur:${#prefix}}"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
fi
return
;;
-*G)
- COMPREPLY=( $(compgen -W "$("$1" -G \? 2>/dev/null | \
+ COMPREPLY=($(compgen -W "$("$1" -G \? 2>/dev/null |
awk '/^[ \t]*-G / \
{ sub("^[[]","",$2); sub("[]]$","",$2); print $2 }')" \
- -- "$cur") )
+ -- "$cur"))
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \
- -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \
+ -- "$cur"))
return
fi
} &&
-complete -F _tshark tshark
+ complete -F _tshark tshark
# ex: filetype=sh