Use the environment variable XREMOTE_HOST as default.
authorFrancois Fleuret <francois@fleuret.org>
Sun, 28 May 2017 05:03:23 +0000 (07:03 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Sun, 28 May 2017 05:03:23 +0000 (07:03 +0200)
xremote.sh

index 9b753e0..ecc1473 100755 (executable)
@@ -54,7 +54,10 @@ xremote.sh <executable>
     @XREMOTE_GET: *.dat
     @XREMOTE_PRE: ln -s /home/fleuret/data/pytorch ./data
 
- Contact <francois@fleuret.org> for comments.
+  If no argument is provided to @XREMOTE_HOST, the environment
+  variable $XREMOTE_HOST is used instead
+
+  Contact <francois@fleuret.org> for comments.
 
 EOF
     return 0
@@ -103,8 +106,9 @@ do
 
             HOST)
                 [[ "${REMOTE_DIR}" ]] && (exit "Remote host already defined!" >&2 && exit 1)
-                cleanup_remote_tmp
-                REMOTE_HOST=${value}
+                REMOTE_HOST="${value}"
+                [[ "${REMOTE_HOST}" ]] || REMOTE_HOST="${XREMOTE_HOST}"
+                [[ "${REMOTE_HOST}" ]] || (echo "No remote host specified." >&2 && exit 1)
                 REMOTE_DIR="$(ssh </dev/null "${REMOTE_HOST}" mktemp -d /tmp/xremote.from_"$(hostname)_$(date +%Y%m%d)".XXXXXX)"
                 ;;
         esac