| 1 |
_nsenter_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
case $prev in |
| 8 |
'-S'|'--uid') |
| 9 |
COMPREPLY=( follow $(compgen -W "uid" -- $cur) ) |
| 10 |
return 0 |
| 11 |
;; |
| 12 |
'-G'|'--gid') |
| 13 |
COMPREPLY=( follow $(compgen -W "gid" -- $cur) ) |
| 14 |
return 0 |
| 15 |
;; |
| 16 |
'-t'|'--target') |
| 17 |
local PIDS |
| 18 |
PIDS=$(builtin cd /proc && echo [0-9]*) |
| 19 |
COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) |
| 20 |
return 0 |
| 21 |
;; |
| 22 |
'-h'|'--help'|'-V'|'--version') |
| 23 |
return 0 |
| 24 |
;; |
| 25 |
esac |
| 26 |
case $cur in |
| 27 |
'=') |
| 28 |
# FIXME: --root and --wd should use get only |
| 29 |
# directories as compgen output. If $cur is |
| 30 |
# overwrote the same way as below in case segment |
| 31 |
# for $prev the command-line will get mangled. |
| 32 |
cur=${cur#=} |
| 33 |
;; |
| 34 |
-*) |
| 35 |
OPTS=" |
| 36 |
--all |
| 37 |
--follow-context |
| 38 |
--target |
| 39 |
--mount= |
| 40 |
--uts= |
| 41 |
--ipc= |
| 42 |
--net= |
| 43 |
--net-socket |
| 44 |
--pid= |
| 45 |
--cgroup= |
| 46 |
--user= |
| 47 |
--user-parent |
| 48 |
--time= |
| 49 |
--setuid |
| 50 |
--setgid |
| 51 |
--keep-caps |
| 52 |
--preserve-credentials |
| 53 |
--root= |
| 54 |
--wd= |
| 55 |
--wdns= |
| 56 |
--env |
| 57 |
--no-fork |
| 58 |
--join-cgroup |
| 59 |
--help |
| 60 |
--version |
| 61 |
" |
| 62 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 63 |
return 0 |
| 64 |
;; |
| 65 |
esac |
| 66 |
local IFS=$'\n' |
| 67 |
compopt -o filenames |
| 68 |
COMPREPLY=( $(compgen -f -- $cur) ) |
| 69 |
return 0 |
| 70 |
} |
| 71 |
complete -F _nsenter_module nsenter |