From ca0ccc561347202d69ef1161930811a54ef48322 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 21 Oct 2016 23:10:47 +0200 Subject: Change host handling: Explicit localhost means force use ssh; no host implies non-ssh (and requires -- before command). --- xsh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'xsh') diff --git a/xsh b/xsh index 9830df1..c7a8364 100755 --- a/xsh +++ b/xsh @@ -3,7 +3,7 @@ SCRIPT=$(basename $0) usage() { - echo "Usage: $SCRIPT [--x] [--verbose] [[su] [{user}@]{host}] [--] [remote command...]" + echo "Usage: $SCRIPT [--x] [--verbose] [[su] [{user}@]{host}] [-- command...]" } termwrapper() { @@ -31,7 +31,6 @@ V='' HOST='' ssh_opts="-t" -args='' while [ $# -gt 0 ]; do case $1 in su) SU=1;; @@ -39,25 +38,12 @@ while [ $# -gt 0 ]; do --ssh2|-2) ssh_opts="$ssh_opts -2";; --verbose|-v) V=1; ssh_opts="$ssh_opts -v";; --port|-p) ssh_opts="$ssh_opts -p $2"; shift;; - --host|-h) HOST=$1;; - -) HOST="localhost";; - --) shift; args="$args$@ "; break;; + --) shift; break;; -*) usage; exit 1;; - *) args="$args$1 ";; + *) [ -z "$HOST" ] && HOST=$1 || break;; esac shift done -set -- $args - -# Make sure we have a hostname -if [ -z "$HOST" ]; then - if [ $# -gt 0 ]; then - HOST=$1 - shift - else - HOST="localhost" - fi -fi # Split program name from its options if [ $# -gt 0 ]; then @@ -90,7 +76,7 @@ prg="$prg_base $prg_opts" prg_su="echo -n 'Changing to root...: '; su -c \"cd; $prg\"" case "$HOST" in - *@localhost|localhost) + '') if [ -n "$SU" ]; then termwrapper $prg_su else -- cgit v1.2.3