2013-03-24 12:19:09 -05:00
|
|
|
_setpriv_module()
|
|
|
|
{
|
|
|
|
local cur prev OPTS
|
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
case $prev in
|
2017-09-17 13:49:02 -05:00
|
|
|
'--ambient-caps'|'--inh-caps'|'--bounding-set')
|
bash-completion: handle comma-separated options
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
$ partx --output END,SECTORS,SCHEME,START,
You got these completions:
END,SECTORS,SCHEME,START,FLAGS, END,SECTORS,SCHEME,START,NR,
END,SECTORS,SCHEME,START,TYPE,
END,SECTORS,SCHEME,START,NAME, END,SECTORS,SCHEME,START,SIZE,
END,SECTORS,SCHEME,START,UUID,
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.
Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-02 12:59:01 -05:00
|
|
|
local prefix realcur INHERIT_ALL INHERIT
|
|
|
|
realcur="${cur##*,}"
|
|
|
|
prefix="${cur%$realcur}"
|
|
|
|
INHERIT_ALL=$($1 --list-caps| awk '{print $1, "-" $1}')
|
|
|
|
for WORD in $INHERIT_ALL; do
|
|
|
|
if ! [[ $prefix == *"$WORD"* ]]; then
|
2017-09-17 13:49:02 -05:00
|
|
|
INHERIT="$WORD ${INHERIT:-""}"
|
bash-completion: handle comma-separated options
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
$ partx --output END,SECTORS,SCHEME,START,
You got these completions:
END,SECTORS,SCHEME,START,FLAGS, END,SECTORS,SCHEME,START,NR,
END,SECTORS,SCHEME,START,TYPE,
END,SECTORS,SCHEME,START,NAME, END,SECTORS,SCHEME,START,SIZE,
END,SECTORS,SCHEME,START,UUID,
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.
Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-02 12:59:01 -05:00
|
|
|
fi
|
|
|
|
done
|
2013-03-24 12:19:09 -05:00
|
|
|
compopt -o nospace
|
bash-completion: handle comma-separated options
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
$ partx --output END,SECTORS,SCHEME,START,
You got these completions:
END,SECTORS,SCHEME,START,FLAGS, END,SECTORS,SCHEME,START,NR,
END,SECTORS,SCHEME,START,TYPE,
END,SECTORS,SCHEME,START,NAME, END,SECTORS,SCHEME,START,SIZE,
END,SECTORS,SCHEME,START,UUID,
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.
Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-02 12:59:01 -05:00
|
|
|
COMPREPLY=( $(compgen -P "$prefix" -W "$INHERIT" -S ',' -- $realcur) )
|
2013-03-24 12:19:09 -05:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
'--ruid'|'--euid'|'--reuid')
|
|
|
|
local UIDS
|
2018-10-04 15:36:22 -05:00
|
|
|
UIDS=$(getent passwd | awk -F: '{print $1}')
|
2013-03-24 12:19:09 -05:00
|
|
|
COMPREPLY=( $(compgen -W "$UIDS" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
'--rgid'|'--egid'|'--regid')
|
|
|
|
local GIDS
|
2018-10-04 15:36:22 -05:00
|
|
|
GIDS=$(getent group | awk -F: '{print $1}')
|
2013-03-24 12:19:09 -05:00
|
|
|
COMPREPLY=( $(compgen -W "$GIDS" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
'--groups')
|
bash-completion: handle comma-separated options
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
$ partx --output END,SECTORS,SCHEME,START,
You got these completions:
END,SECTORS,SCHEME,START,FLAGS, END,SECTORS,SCHEME,START,NR,
END,SECTORS,SCHEME,START,TYPE,
END,SECTORS,SCHEME,START,NAME, END,SECTORS,SCHEME,START,SIZE,
END,SECTORS,SCHEME,START,UUID,
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.
Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-02 12:59:01 -05:00
|
|
|
local prefix realcur GIDS_ALL GIDS
|
|
|
|
realcur="${cur##*,}"
|
|
|
|
prefix="${cur%$realcur}"
|
|
|
|
GIDS_ALL=$(getent group | awk -F: '{print $3}')
|
|
|
|
for WORD in $GIDS_ALL; do
|
|
|
|
if ! [[ $prefix == *"$WORD"* ]]; then
|
2018-04-05 14:56:53 -05:00
|
|
|
GIDS="$WORD ${GIDS:-""}"
|
bash-completion: handle comma-separated options
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
$ partx --output END,SECTORS,SCHEME,START,
You got these completions:
END,SECTORS,SCHEME,START,FLAGS, END,SECTORS,SCHEME,START,NR,
END,SECTORS,SCHEME,START,TYPE,
END,SECTORS,SCHEME,START,NAME, END,SECTORS,SCHEME,START,SIZE,
END,SECTORS,SCHEME,START,UUID,
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.
Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-02 12:59:01 -05:00
|
|
|
fi
|
|
|
|
done
|
2013-03-24 12:19:09 -05:00
|
|
|
compopt -o nospace
|
bash-completion: handle comma-separated options
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
$ partx --output END,SECTORS,SCHEME,START,
You got these completions:
END,SECTORS,SCHEME,START,FLAGS, END,SECTORS,SCHEME,START,NR,
END,SECTORS,SCHEME,START,TYPE,
END,SECTORS,SCHEME,START,NAME, END,SECTORS,SCHEME,START,SIZE,
END,SECTORS,SCHEME,START,UUID,
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.
Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-02 12:59:01 -05:00
|
|
|
COMPREPLY=( $(compgen -P "$prefix" -W "$GIDS" -S ',' -- $realcur) )
|
2013-03-24 12:19:09 -05:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
'--securebits')
|
2018-04-05 14:56:55 -05:00
|
|
|
local prefix realcur SBITS_ALL SBITS WORD
|
|
|
|
realcur="${cur##*,}"
|
|
|
|
prefix="${cur%$realcur}"
|
|
|
|
SBITS_ALL="
|
|
|
|
{+,-}keep_caps_locked
|
|
|
|
{+,-}noroot
|
|
|
|
{+,-}noroot_locked
|
|
|
|
{+,-}no_setuid_fixup
|
|
|
|
{+,-}no_setuid_fixup_locked
|
|
|
|
"
|
|
|
|
for WORD in $SBITS_ALL; do
|
|
|
|
if ! [[ $prefix == *"$WORD"* ]]; then
|
|
|
|
SBITS="$WORD ${SBITS:-""}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
compopt -o nospace
|
|
|
|
COMPREPLY=( $(compgen -P "$prefix" -W "$SBITS" -S ',' -- $realcur) )
|
2013-03-24 12:19:09 -05:00
|
|
|
return 0
|
|
|
|
;;
|
2018-10-04 15:36:22 -05:00
|
|
|
'--pdeathsig')
|
|
|
|
local i signals
|
|
|
|
for i in $(kill -l); do
|
|
|
|
case $i in
|
|
|
|
SIG*)
|
|
|
|
signals+="$i "
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
COMPREPLY=( $(compgen -W "keep clear $signals" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
2013-03-24 12:19:09 -05:00
|
|
|
'--selinux-label')
|
|
|
|
# FIXME: how to list selinux labels?
|
|
|
|
COMPREPLY=( $(compgen -W "label" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
'--apparmor-profile')
|
|
|
|
# FIXME: how to list apparmor profiles?
|
|
|
|
COMPREPLY=( $(compgen -W "profile" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
2013-04-07 03:12:04 -05:00
|
|
|
'-h'|'--help'|'-V'|'--version')
|
|
|
|
return 0
|
|
|
|
;;
|
2013-03-24 12:19:09 -05:00
|
|
|
esac
|
|
|
|
case $cur in
|
|
|
|
-*)
|
2013-04-07 03:12:08 -05:00
|
|
|
OPTS="--dump
|
|
|
|
--no-new-privs
|
2017-09-17 13:49:02 -05:00
|
|
|
--ambient-caps
|
2013-03-24 12:19:09 -05:00
|
|
|
--inh-caps
|
|
|
|
--bounding-set
|
|
|
|
--ruid
|
|
|
|
--euid
|
|
|
|
--rgid
|
|
|
|
--egid
|
|
|
|
--reuid
|
|
|
|
--regid
|
|
|
|
--clear-groupsclear
|
|
|
|
--keep-groupskeep
|
|
|
|
--groups
|
|
|
|
--securebits
|
2018-10-04 15:36:22 -05:00
|
|
|
--pdeathsig
|
|
|
|
--reset-env
|
2013-03-24 12:19:09 -05:00
|
|
|
--selinux-label
|
|
|
|
--apparmor-profile
|
2013-04-07 03:12:08 -05:00
|
|
|
--help
|
|
|
|
--version"
|
2013-03-24 12:19:09 -05:00
|
|
|
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
compopt -o bashdefault
|
|
|
|
COMPREPLY=( $(compgen -c -- $cur) )
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
complete -F _setpriv_module setpriv
|