aboutgitcodebugslistschat
path: root/slirp4netns.sh
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-21 20:37:51 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-21 20:37:51 +0200
commit94c7c1dbcf29e71355516c499973a7fdd9402948 (patch)
treece02e121b2101bec2c96447330e5b463acd58db6 /slirp4netns.sh
parent1fc6416cf9446cbf75818fd61772610e74709065 (diff)
downloadpasst-94c7c1dbcf29e71355516c499973a7fdd9402948.tar
passt-94c7c1dbcf29e71355516c499973a7fdd9402948.tar.gz
passt-94c7c1dbcf29e71355516c499973a7fdd9402948.tar.bz2
passt-94c7c1dbcf29e71355516c499973a7fdd9402948.tar.lz
passt-94c7c1dbcf29e71355516c499973a7fdd9402948.tar.xz
passt-94c7c1dbcf29e71355516c499973a7fdd9402948.tar.zst
passt-94c7c1dbcf29e71355516c499973a7fdd9402948.zip
slirp4netns.sh: Fix up usage, exit 0 on --help
Based on an original patch by Giuseppe Scrivano: there's no need to pass $0 to usage, drop that everywhere, and make it consistent. Don't exit with error on -h, --help. Suggested-by: Giuseppe Scrivano <gscrivan@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'slirp4netns.sh')
-rwxr-xr-xslirp4netns.sh11
1 files changed, 6 insertions, 5 deletions
diff --git a/slirp4netns.sh b/slirp4netns.sh
index f543e9b..de74281 100755
--- a/slirp4netns.sh
+++ b/slirp4netns.sh
@@ -17,6 +17,7 @@
PASTA_PID="$(mktemp)"
PASTA_OPTS="-q --ipv4-only -a 10.0.2.0 -n 24 -g 10.0.2.2 -m 1500 --no-ndp --no-dhcpv6 --no-dhcp -P ${PASTA_PID}"
+USAGE_RET=1
# add() - Add single option to $PASTA_OPTS
# $1: Option name, with or without argument
@@ -111,7 +112,7 @@ opt() {
# usage() - Print slirpnetns(1) usage and exit indicating failure
# $1: Invalid option name, if any
usage() {
- [ ${#} -eq 1 ] && printf "s: invalid option -- '%s'\n" "${0}" "${1}"
+ [ ${#} -eq 1 ] && printf "%s: invalid option -- '%s'\n" "${0}" "${1}"
cat << EOF
Usage: ${0} [OPTION]... PID|PATH TAPNAME
User-mode networking for unprivileged network namespaces.
@@ -131,7 +132,7 @@ User-mode networking for unprivileged network namespaces.
-h, --help show this help and exit
-v, --version show version and exit
EOF
- exit 1
+ exit ${USAGE_RET}
}
# version() - Print version
@@ -178,10 +179,10 @@ while getopts ce:r:m:6a:hv-: OPT 2>/dev/null; do
userns-path) opt_str USERNS_NAME "${OPTARG}" ;;
enable-sandbox) : Not supported yet ;;
enable-seccomp) : Cannot be disabled ;;
- h | help) usage "${0}" ;;
+ h | help) USAGE_RET=0 && usage ;;
v | version) version ;;
- ??*) usage "${0}" "${OPT}" ;;
- ?) usage "${0}" ;;
+ ??*) usage "${OPT}" ;;
+ ?) usage "${OPT}" ;;
esac
done