]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Update `_lxc_usernsexec`.
authorEdênis Freindorfer Azevedo <edenisfa@gmail.com>
Fri, 3 Sep 2021 13:01:45 +0000 (10:01 -0300)
committerEdênis Freindorfer Azevedo <edenisfa@gmail.com>
Wed, 8 Sep 2021 01:24:06 +0000 (22:24 -0300)
Not really much can be done for this function, as `-m` requires an ID
mapping that has to be manually input, since it will use
`/etc/sub{g,u}id` if not specified.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
config/bash/lxc.in

index a4306b496063539a897595094bcb1fec3e38ad17..7254e7351b5ce73f6c4f0e2c015d2d3f08e88f55 100644 (file)
@@ -1124,6 +1124,14 @@ _lxc_update_config() {
 } &&
     complete -F _lxc_update_config lxc-update-config
 
+__lxc_id_mapping() {
+    local -r tmp="${cur//[^:]}"
+    if [[ "${#tmp}" -eq 0 ]]; then
+        COMPREPLY=( $( compgen -W "u: g: b:" -- "${cur}" ) )
+    fi
+    compopt -o nospace
+}
+
 _lxc_usernsexec() {
     local cur prev words cword split
     COMPREPLY=()
@@ -1139,7 +1147,8 @@ _lxc_usernsexec() {
             return
             ;;
         -m )
-            # @TODO: ^[ugb]:[0-9]+:[0-9]+(:[0-9]+)?$
+            # ^[ugb]:[0-9]+:[0-9]+(:[0-9]+)?$
+            __lxc_id_mapping
             return
             ;;
         -s )
@@ -1152,7 +1161,6 @@ _lxc_usernsexec() {
     if [[ ${cur} == -* ]]; then
         COMPREPLY=( $( compgen -W '-h -m -s' -- "${cur}" ) )
         [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
-        return
     fi
 } &&
     complete -F _lxc_usernsexec lxc-usernsexec