aboutsummaryrefslogtreecommitdiff
path: root/psshd
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-09-14 17:20:47 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-09-14 17:45:16 +1200
commitac11b805e42d705e75fd8f0df8e00544ae54735c (patch)
tree0104e44242b1c324ef1a5c363590a4d894f313db /psshd
parentInclude self name in error messages (diff)
downloadpsshd-ac11b805e42d705e75fd8f0df8e00544ae54735c.tar.gz
psshd-ac11b805e42d705e75fd8f0df8e00544ae54735c.zip
Do away with getopts completely, just use arg
Diffstat (limited to 'psshd')
-rwxr-xr-xpsshd32
1 files changed, 8 insertions, 24 deletions
diff --git a/psshd b/psshd
index 22261f1..1a86c9d 100755
--- a/psshd
+++ b/psshd
@@ -4,11 +4,10 @@
# Wrapper around autossh and start-stop-daemon for basic persistence. Intended
# to be called as a script from profile.d for automatic SSH tunnels.
#
-# Takes one required option -p, the autossh monitoring port number to use. Cut
-# the options off with -- and the remainder of the arguments are passed to the
-# autossh binary.
+# Uses one argument, the autossh monitoring port number to use. The remainder
+# of the arguments are passed to the autossh binary.
#
-# $ psshd -p 9001 -- -fN -D 8001 remotehost
+# $ psshd 9001 -fN -D 8001 remotehost
#
# @author Tom Ryder <tom@sanctum.geek.nz>
# @copyright 2013
@@ -29,27 +28,12 @@ for cmd in "${cmds[@]}"; do
fi
done
-# Get port in options
-while getopts :p: opt; do
- case $opt in
- p)
- port=$OPTARG
- ;;
- \?)
- printf '%s - Invalid option %s\n' "$self" "$OPTARG" >&2
- exit 1
- ;;
- :)
- printf '%s - Option -%s requires an argument\n' "$self" "$OPTARG" >&2
- exit 1
- ;;
- esac
-done
-shift $((OPTIND-1))
-
# If no port, give up with usage instructions
-if ! [[ $port ]]; then
- printf 'USAGE: %s -p <port number> -- <ssh arguments>\n' "$self"
+if (($# > 0)); then
+ port=$1
+ shift
+else
+ printf 'USAGE: %s <port number> -- <ssh arguments>\n' "$self"
exit 1
fi