diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | bash_completion/nsdo | 20 | ||||
-rw-r--r-- | nsdo.1 | 2 |
5 files changed, 33 insertions, 8 deletions
@@ -1,3 +1,3 @@ -nsdo -nsdo.1.gz +/nsdo +/nsdo.1.gz .*.sw? @@ -1,5 +1,9 @@ CFLAGS ?= -Wall -Werror -O3 +# if you're building a system package, you should probably set these to +# /usr, /usr/share/bash-completion/completions, and your package dir PREFIX ?= /usr/local +BASH_COMPLETION_DIR ?= /etc/bash_completion.d +DESTDIR ?= PROG = nsdo MANSECTION = 1 @@ -12,14 +16,15 @@ README = README.md all: $(PROG) $(MANPAGEGZ) $(README) install: $(PROG) $(MANPAGEGZ) - install -Dm6755 $< $(PREFIX)/bin/$< - install -Dm644 $(word 2,$^) $(PREFIX)/share/man/man$(MANSECTION)/$(word 2,$^) + install -Dm4755 $< $(DESTDIR)$(PREFIX)/bin/$< + install -Dm644 $(word 2,$^) $(DESTDIR)$(PREFIX)/share/man/man$(MANSECTION)/$(word 2,$^) + install -Dm644 bash_completion/$(PROG) $(DESTDIR)$(BASH_COMPLETION_DIR)/$(PROG) clean: rm -fv $(PROG) $(MANPAGEGZ) $(README) $(MANPAGEGZ): $(MANPAGE) - gzip --best -k $< + gzip --best -f -k $< $(README): readme.head $(MANPAGE) { \ @@ -64,8 +64,8 @@ manpage DESCRIPTION Execute command as the current user/group in namespace, a - Linux network namespace set up with iproute2 (see ip-netns - (8)). + Linux network namespace set up with iproute2 (see ip- + netns(8)). By default, iproute2 places network namespaces in /var/run/netns/, so nsdo searces for namespaces there diff --git a/bash_completion/nsdo b/bash_completion/nsdo new file mode 100644 index 0000000..c3e32f1 --- /dev/null +++ b/bash_completion/nsdo @@ -0,0 +1,20 @@ +# nsdo(1) completion -*- shell-script -*- + +_nsdo() +{ + local cur prev words cword + _init_completion || return + + if [[ $COMP_CWORD -eq 1 ]]; then + compopt -o filenames + + # assume that the filenames in /var/run/netns don't contain + # newlines(!) + local IFS=$'\n' + COMPREPLY=( $(compgen -W "$(ip netns list)" -- "$cur") ) + else + _command_offset 2 + fi +} && complete -F _nsdo nsdo + +# ex: ts=4 sw=4 et filetype=sh @@ -6,7 +6,7 @@ nsdo \- run a command in a network namespace .I namespace command [\fIargs\fR ...] .SH DESCRIPTION -Execute \fIcommand\fR as the current user/group in \fInamespace\fR, a Linux network namespace set up with \fBiproute2\fR (see \fBip-netns (8)\fR). +Execute \fIcommand\fR as the current user/group in \fInamespace\fR, a Linux network namespace set up with \fBiproute2\fR (see \fBip-netns(8)\fR). .PP By default, \fBiproute2\fR places network namespaces in /var/run/netns/, so \fBnsdo\fR searces for namespaces there (including \fInamespace\fR). To prevent \fIcommand\fR from easily escaping the namespace 'jail,' \fBnsdo\fR will exit if the current namespace exists in that directory. |