JAL-3830 Allow paths to start with '~'. Make path check more succinct.
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 17 Mar 2021 23:15:11 +0000 (23:15 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 17 Mar 2021 23:15:11 +0000 (23:15 +0000)
utils/getdown/jalviewc

index 29beb98..08c5494 100755 (executable)
@@ -82,10 +82,10 @@ if [ "${ISMACOS}" != 1 ]; then # macos doesn't like uname -o, best to avoid
   # CYGWIN
     echo "When using relative paths in args within Cygwin, please start with './' or '../'" >&2
     CLASSPATH=$(cygpath -pw "${CLASSPATH}")
-    # now for some arg paths fun. only translating paths starting with './', '../' or '/'
+    # now for some arg paths fun. only translating paths starting with './', '../', '/' or '~'
     ARGS=()
     for ARG in "${@}"; do
-      if [ "${ARG}" != "${ARG#./}" -o "${ARG}" != "${ARG#/}" -o "${ARG}" != "${ARG#../}" ]; then
+      if [ "${ARG}" != "${ARG#@(/|./|../|~)}" ]; then
         ARGS=( "${ARGS[@]}" "$(cygpath -aw "${ARG}")" )
       else
         ARGS=( "${ARGS[@]}" "${ARG}" )
@@ -101,7 +101,7 @@ if [ "${ISMACOS}" != 1 ]; then # macos doesn't like uname -o, best to avoid
     done
     ARGS=()
     for ARG in "${@}"; do
-      if [ "${ARG}" != "${ARG#./}" -o "${ARG}" != "${ARG#/}" -o "${ARG}" != "${ARG#../}" ]; then
+      if [ "${ARG}" != "${ARG#@(/|./|../|~)}" ]; then
         # annoyingly wslpath does not work if the file doesn't exist!
         ARGBASENAME="$(basename "${ARG}")"
         ARGDIRNAME="$(dirname "${ARG}")"