From: Oliver Kiddle <opk@zsh.org>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: completions for nsenter and unshare
Date: Sat, 06 Feb 2021 00:01:15 +0100 [thread overview]
Message-ID: <99428-1612566075.809623@LG9H.dOXj.0BXO> (raw)
These are a couple more util-linux commands for which we lacked a
completion. Maybe not the most widely used ones but I kept trying -p
instead of -t on nsenter and completing the commands is also useful.
I made unshare fallback to _default on a non-Linux system because an
unrelated unshare command exists on some systems, e.g. Solaris for
un-sharing NFS exports.
Oliver
diff --git a/Completion/Linux/Command/_nsenter b/Completion/Linux/Command/_nsenter
new file mode 100644
index 000000000..8e7c6bc42
--- /dev/null
+++ b/Completion/Linux/Command/_nsenter
@@ -0,0 +1,28 @@
+#compdef nsenter
+
+local ign
+(( $#words > 2 )) && ign='!'
+
+_arguments -S -s \
+ '(-a --all)'{-a,--all}'[enter all namespaces]' \
+ '(-t --target)'{-t+,--target=}'[specify target process to get namespaces from]:pid:_pids' \
+ '(-m --mount)'{-m-,--mount=-}'[enter mount namespace]::file:_files' \
+ '(-u --uts)'{-u-,--uts=-}'[enter UTS namespace (hostname etc)]::file:_files' \
+ '(-i --ipc)'{-i-,--ipc=-}'[enter System V IPC namespace]::file:_files' \
+ '(-n --net)'{-n-,--net=-}'[enter network namespace]::file:_files' \
+ '(-p --pid)'{-p-,--pid=-}'[enter pid namespace]::file:_files' \
+ '(-C --cgroup)'{-C-,--cgroup=-}'[enter cgroup namespace]::file:_files' \
+ '(-U --user)'{-U-,--user=-}'[enter user namespace]::file:_files' \
+ '(-T --time)'{-T-,--time=-}'[enter time namespace]::file:_files' \
+ '(-S --setuid)'{-S+,--setuid=}'[set uid in entered namespace]:uid [0]' \
+ '(-G --setgid)'{-G+,--setgid=}'[set gid in entered namespace]:gid [0]' \
+ "--preserve-credentials[don't touch uids or gids]" \
+ '(-r --root)'{-r+,--root=}'[set the root directory]:directory:_directories' \
+ '(-w --wd)'{-w+,--wd=}'[set the working directory]:directory:_directories' \
+ '(-F --no-fork)'{-F,--no-fork}"[don't fork]" \
+ '(-Z --follow-context)'{-Z,--follow-context}'[set SELinux context according to --target PID]' \
+ "${ign}(- 1 *)"{-h,--help}'[display usage information]' \
+ "${ign}(- 1 *)"{-V,--version}'[display version information]' \
+ '1: : _command_names -e' \
+ '*::args :_normal'
+
diff --git a/Completion/Linux/Command/_unshare b/Completion/Linux/Command/_unshare
new file mode 100644
index 000000000..ff6f7042f
--- /dev/null
+++ b/Completion/Linux/Command/_unshare
@@ -0,0 +1,40 @@
+#compdef unshare
+
+local ign
+(( $#words > 2 )) && ign='!'
+
+# a different unshare exists on some systems
+if [[ $OSTYPE != linux* ]]; then
+ _default
+ return
+fi
+
+_arguments -S -s \
+ '(-m --mount)'{-m-,--mount=-}'[enter mount namespace]::file:_files' \
+ '(-u --uts)'{-u-,--uts=-}'[enter UTS namespace (hostname etc)]::file:_files' \
+ '(-i --ipc)'{-i-,--ipc=-}'[enter System V IPC namespace]::file:_files' \
+ '(-n --net)'{-n-,--net=-}'[enter network namespace]::file:_files' \
+ '(-p --pid)'{-p-,--pid=-}'[enter pid namespace]::file:_files' \
+ '(-U --user)'{-U-,--user=-}'[enter user namespace]::file:_files' \
+ '(-C --cgroup)'{-C-,--cgroup=-}'[enter cgroup namespace]::file:_files' \
+ '(-T --time)'{-T-,--time=-}'[enter time namespace]::file:_files' \
+ '(-f --fork)'{-f,--fork}"[fork before launching]" \
+ '(-r --map-root-user)--map-user=[map current user to uid (implies --user)]:user:_users' \
+ '--map-group=[map current group to gid (implies --user)]:group:_groups' \
+ '(-r --map-root-user -c --map-current-user --map-user)'{-r,--map-root-user}'[map current user to root (implies --user)]' \
+ '(-c --map-current-user)'{-c,--map-current-user}'[map current user to itself (implies --user)]' \
+ '(-f --fork)--kill-child=-[when dying, kill the forked child (implies --fork)]::signal [KILL]:_signals' \
+ '--mount-proc=-[mount proc filesystem first (implies --mount)]::mount point [/proc]:_directories' \
+ '--propagation=[modify mount propagation in mount namespace]:propagation flag:(slave shared private unchanged)' \
+ '--setgroups=[control the setgroups syscall in user namespaces]:grant setgroups:(allow deny)' \
+ '--keep-caps[retain capabilities granted in user namespaces]' \
+ '(-R --root)'{-R+,--root=}'[set the root directory]:directory:_directories' \
+ '(-w --wd)'{-w+,--wd=}'[set the working directory]:directory:_directories' \
+ '(-S --setuid)'{-S+,--setuid=}'[set uid in entered namespace]:uid [0]' \
+ '(-G --setgid)'{-G+,--setgid=}'[set gid in entered namespace]:gid [0]' \
+ '--monotonic=[set clock monotonic offset in time namespaces]:offset (seconds)' \
+ '--boottime=[set clock boottime offset in time namespaces]:offset (seconds)' \
+ "${ign}(- 1 *)"{-h,--help}'[display usage information]' \
+ "${ign}(- 1 *)"{-V,--version}'[display version information]' \
+ '1: : _command_names -e' \
+ '*::args :_normal'
reply other threads:[~2021-02-05 23:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=99428-1612566075.809623@LG9H.dOXj.0BXO \
--to=opk@zsh.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).