fix for testing whether it's windows or not, had all upper case but Windows_NT is...
[feisty_meow.git] / scripts / core / functions.sh
index 0f185ee5288710a4657fc0ae05ad25b1601f2695..eee56fe36c4156e3c8bf6c65aa090bdac4aa5efe 100644 (file)
@@ -237,11 +237,22 @@ if [ -z "$skip_all" ]; then
   # switches from a /X/path form to an X:/ form.  this also processes cygwin paths.
   function unix_to_dos_path() {
     # we usually remove dos slashes in favor of forward slashes.
+    local DOSSYHOME
+    if [[ ! "$OS" =~ ^[Ww][iI][nN] ]]; then
+      # fake this value for non-windows (non-cygwin) platforms.
+      DOSSYHOME="$HOME"
+    else
+      # for cygwin, we must replace the /home/X path with an absolute one, since cygwin
+      # insists on the /home form instead of /c/cygwin/home being possible.  this is
+      # super frustrating and nightmarish.
+      DOSSYHOME="$(cygpath -am "$HOME")"
+    fi
+
     if [ ! -z "$SERIOUS_SLASH_TREATMENT" ]; then
       # unless this flag is set, in which case we force dos slashes.
-      echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\/cygdrive//' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/' | sed -e 's/\//\\/g'
+      echo "$1" | sed -e "s?^$HOME?$DOSSYHOME?g" | sed -e 's/\\/\//g' | sed -e 's/\/cygdrive//' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/' | sed -e 's/\//\\/g'
     else
-      echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\/cygdrive//' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/'
+      echo "$1" | sed -e "s?^$HOME?$DOSSYHOME?g" | sed -e 's/\\/\//g' | sed -e 's/\/cygdrive//' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/'
     fi
   }