diff options
author | Jonas Smedegaard <dr@jones.dk> | 2016-10-21 23:10:47 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2016-10-22 02:03:15 +0200 |
commit | ca0ccc561347202d69ef1161930811a54ef48322 (patch) | |
tree | 45f4190f9bca403e93f510419a016a4ec6b0cc2f | |
parent | 66bfa9d1afe3381e8e09ed9470328841d0c38714 (diff) |
Change host handling: Explicit localhost means force use ssh; no host implies non-ssh (and requires -- before command).
-rwxr-xr-x | xmc | 11 | ||||
-rwxr-xr-x | xsh | 22 |
2 files changed, 5 insertions, 28 deletions
@@ -1,12 +1,3 @@ #!/bin/bash -# danish locale is broken - see http://bugs.debian.org/181027 -#export LC_ALL=C - -if [ $# -eq 0 ]; then - xsh localhost mc -elif [ $# -eq 1 -a "$1" = "su" ]; then - xsh localhost mc su -else - xsh $@ mc -fi +exec xsh $@ -- mc @@ -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 |