for i in "${!names[@]}"; do
# For composed names with spaces escaped by '\'.
names[${i}]=$(command printf "%q" "${names[${i}]}")
- if [[ -n $(compgen -W "${names[${i}]}" -- "$cur") ]]; then
+ if [[ -n $(compgen -W "${names[${i}]}" -- "${cur}") ]]; then
COMPREPLY+=("${names[${i}]}")
fi
done
return
fi
for name in "${names[@]}"; do
- [[ "${parsed}" = "${name}" ]] && return
+ [[ "${parsed}" == "${name}" ]] && return
done
done
_lxc_names
_lxc_common_opt() {
# End of options.
- if [[ "${words[@]}" =~ ' -- ' ]]; then
+ if [[ "${words[*]}" =~ ' -- ' ]]; then
return 1
fi
- case $prev in
+ case ${prev} in
--help | -h | -\? | --usage | --version )
return 1
;;
return 1
;;
--logpriority | -l )
- COMPREPLY=( $(compgen -W 'FATAL CRIT WARN ERROR NOTICE INFO DEBUG' -- "$cur") )
+ COMPREPLY=( $(compgen -W 'FATAL CRIT WARN ERROR NOTICE INFO DEBUG' -- "${cur}") )
return 1
;;
--quiet | -q )
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
;;
--arch | -a )
# https://github.com/lxc/lxc/blob/stable-4.0/src/tests/arch_parse.c#L37
- COMPREPLY=( $( compgen -W 'arm armel armhf armv7l athlon i386 i486 i586 i686 linux32 mips mipsel ppc powerpc x86 aarch64 amd64 arm64 linux64 mips64 mips64el ppc64 ppc64el ppc64le powerpc64 s390x x86_64' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W 'arm armel armhf armv7l athlon i386 i486 i586 i686 linux32 mips mipsel ppc powerpc x86 aarch64 amd64 arm64 linux64 mips64 mips64el ppc64 ppc64el ppc64le powerpc64 s390x x86_64' -- "${cur}" ) )
return
;;
--elevated-privileges | -e )
- __lxc_piped_args "$cur" '|' CGROUP CAP LSM
+ __lxc_piped_args "${cur}" '|' CGROUP CAP LSM
return
;;
--namespaces | -s )
- __lxc_piped_args "$cur" '|' MOUNT PID UTSNAME IPC USER NETWORK
+ __lxc_piped_args "${cur}" '|' MOUNT PID UTSNAME IPC USER NETWORK
return
;;
--remount-sys-proc | -R | --keep-env | --clear-env )
return
;;
--keep-var )
- COMPREPLY=( $( compgen -A variable -- "$cur" ) )
+ COMPREPLY=( $( compgen -A variable -- "${cur}" ) )
return
;;
--uid | -u )
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--reboot | -r | --shutdown | -s | --kill | -k | --list | -L | --all | -a | --ignore-auto | -A )
# Only flags.
;;
--timeout | -t )
- COMPREPLY=( $( compgen -P "$cur" -W "{0..9}" ) )
+ COMPREPLY=( $( compgen -P "${cur}" -W "{0..9}" ) )
compopt -o nospace
return
;;
--groups | -g )
# @TODO: add NULL group as a leading comma, trailing comma, embedded double comma.
- __lxc_piped_args "$cur" ',' $( __lxc_groups )
+ __lxc_piped_args "${cur}" ',' $( __lxc_groups )
return
;;
esac
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-l' -- "$cur"))
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=($(compgen -W '-l' -- "${cur}"))
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- COMPREPLY=( $( compgen -W "$( command lxc-config -l )" -- "$cur" ) )
+ COMPREPLY=( $( compgen -W "$( command lxc-config -l )" -- "${cur}" ) )
}
complete -F _lxc_config lxc-config
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
return
;;
--escape | -e )
- COMPREPLY+=( $( compgen -P "'" -S "'" -W "^{a..z} {a..z}" -- "$cur" ) )
+ COMPREPLY+=( $( compgen -P "'" -S "'" -W "^{a..z} {a..z}" -- "${cur}" ) )
return
;;
--tty | -t )
- COMPREPLY=( $( compgen -P "$cur" -W "{0..9}" ) )
+ COMPREPLY=( $( compgen -P "${cur}" -W "{0..9}" ) )
compopt -o nospace
return
;;
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
complete -F _lxc_console lxc-console
__lxc_backing_stores() {
- COMPREPLY=( $( compgen -W 'best btrfs dir loop lvm nbd overlay overlayfs rbd zfs' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W 'best btrfs dir loop lvm nbd overlay overlayfs rbd zfs' -- "${cur}" ) )
}
_lxc_copy() {
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
complete -F _lxc_copy lxc-copy
__lxc_templates() {
- COMPREPLY=( $( compgen -W "$(command ls @LXCTEMPLATEDIR@/ | command sed -e 's|^lxc-||' )" -- "$cur" ) )
+ COMPREPLY=( $( compgen -W "$(command ls @LXCTEMPLATEDIR@/ | command sed -e 's|^lxc-||' )" -- "${cur}" ) )
}
_lxc_create() {
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
COMPREPLY=()
_init_completion -s -n : || return
- case $prev in
+ case ${prev} in
-h )
return
;;
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--line | -1 | --fancy | -f | --active | --frozen | --running | --stopped | --defined )
# Only flags.
;;
;;
--groups | -g )
# @TODO: add NULL group as a leading comma, trailing comma, embedded double comma.
- __lxc_piped_args "$cur" ',' $( __lxc_groups )
+ __lxc_piped_args "${cur}" ',' $( __lxc_groups )
return
;;
--nesting )
- COMPREPLY=( $( compgen -P "$cur" -W "{0..9}" ) )
+ COMPREPLY=( $( compgen -P "${cur}" -W "{0..9}" ) )
compopt -o nospace
return
;;
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
return
;;
--destroy | -d )
- COMPREPLY=( $( compgen -W 'ALL $( lxc-snapshot --list )' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W 'ALL $( lxc-snapshot --list )' -- "${cur}" ) )
return
;;
--list | -L | --showcomments | -C )
# Only flags.
;;
--restore | -r )
- COMPREPLY=( $( compgen -W '$( lxc-snapshot --list )' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W '$( lxc-snapshot --list )' -- "${cur}" ) )
return
;;
--newname | -N )
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
;;
--share-net | --share-ipc | --share-uts )
_pids
- COMPREPLY+=( $( compgen -W "$( command lxc-ls --active )" -- "$cur" ) )
+ COMPREPLY+=( $( compgen -W "$( command lxc-ls --active )" -- "${cur}" ) )
return
;;
esac
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
# Needed due to weird `_parse_help` output for the `--share-*` options.
- COMPREPLY=( $( compgen -W '${COMPREPLY[@]/--share-} --share-net --share-ipc --share-uts' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W '${COMPREPLY[@]/--share-} --share-net --share-ipc --share-uts' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
# Only flags.
;;
--timeout | -t )
- COMPREPLY=( $( compgen -P "$cur" -W "{0..9}" ) )
+ COMPREPLY=( $( compgen -P "${cur}" -W "{0..9}" ) )
compopt -o nospace
return
;;
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--batch | -b | --reverse | -r )
# Only flags.
;;
--delay | -d )
- COMPREPLY=( $( compgen -P "$cur" -W "{0..9}" ) )
+ COMPREPLY=( $( compgen -P "${cur}" -W "{0..9}" ) )
compopt -o nospace
return
;;
--sort | -s )
- COMPREPLY=( $( compgen -W 'n c b m k' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W 'n c b m k' -- "${cur}" ) )
return
;;
esac
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--namespaces | -s )
- __lxc_piped_args "$cur" '|' MOUNT PID UTSNAME IPC USER NETWORK
+ __lxc_piped_args "${cur}" '|' MOUNT PID UTSNAME IPC USER NETWORK
return
;;
--user | -u )
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
COMPREPLY=()
_init_completion -s -n : || return
- case $prev in
+ case ${prev} in
--help | -h )
return
;;
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_init_completion -s -n : || return
# End of options.
- if [[ "${words[@]}" =~ ' -- ' ]]; then
+ if [[ "${words[*]}" =~ ' -- ' ]]; then
return
fi
- case $prev in
+ case ${prev} in
-h )
return
;;
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '-h -m -s' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '-h -m -s' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
_lxc_common_opt || return
- case $prev in
+ case ${prev} in
--name | -n )
_lxc_names
return
return
;;
--state | -s )
- __lxc_piped_args "$cur" '|' STOPPED STARTING RUNNING STOPPING ABORTING FREEZING FROZEN THAWED
+ __lxc_piped_args "${cur}" '|' STOPPED STARTING RUNNING STOPPING ABORTING FREEZING FROZEN THAWED
return
;;
--timeout | -t )
- COMPREPLY=( $( compgen -P "$cur" -W "{0..9}" ) )
+ COMPREPLY=( $( compgen -P "${cur}" -W "{0..9}" ) )
compopt -o nospace
return
;;
$split && return
- if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi