OCD cosmetics.
[xremote.git] / xremote.sh
index 9752a9a..5536d01 100755 (executable)
@@ -56,6 +56,10 @@ xremote.sh [-h <remote_host>] [-i <remote_dir>] <script> [script arguments]
     @XREMOTE_GET: *.dat
     @XREMOTE_PRE: ln -s /home/fleuret/data/pytorch ./data
 
+  If a file with the same name as the script with the .xremote
+  extension appended to it exists, arguments will be read from it by
+  default.
+
   If the -h option is provided @XREMOTE_HOST is ignored.
 
   If the -i option is provided, all the files are installed and
@@ -107,11 +111,19 @@ done
 
 ######################################################################
 
-[[ -a "$1" ]] || (help && exit 1)
+[[ -a "$1" ]] || (help && echo >&2 "Cannot find $1" && exit 1)
+
+cd "$(dirname "$1")"
 
 main="$(basename "$1")"
+main_config="${main}.xremote"
 
-cd "$(dirname "$1")"
+if [[ -f "${main_config}" ]]
+then
+    echo "xremote: found ${main_config}"
+else
+    main_config="${main}"
+fi
 
 shift
 
@@ -166,7 +178,7 @@ do
         esac
     fi
 
-done < "${main}"
+done < "${main_config}"
 
 ######################################################################
 
@@ -192,6 +204,7 @@ fi
 ######################################################################
 
 # I find this slightly ugly ...
+
 for s in "$@"
 do
   quoted_args="${quoted_args} \"${s}\""
@@ -226,7 +239,8 @@ do
                 ;;
         esac
     fi
-done < "${main}"
+
+done < "${main_config}"
 
 set +f