cygwin-wrapper 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. #
  6. # Stupid wrapper to avoid win32 dospath/cygdrive issues
  7. # Try not to spawn programs from within this file. If the stuff in here looks royally
  8. # confusing, see bug: http://bugzilla.mozilla.org/show_bug.cgi?id=206643
  9. # and look at the older versions of this file that are easier to read, but
  10. # do basically the same thing
  11. #
  12. prog=$1
  13. shift
  14. if test -z "$prog"; then
  15. exit 0
  16. fi
  17. # If $CYGDRIVE_MOUNT was not set in configure, give $mountpoint the results of mount -p
  18. mountpoint=$CYGDRIVE_MOUNT
  19. if test -z "$mountpoint"; then
  20. mountpoint=`mount -p`
  21. if test -z "$mountpoint"; then
  22. print "Cannot determine cygwin mount points. Exiting"
  23. exit 1
  24. fi
  25. fi
  26. # Delete everything but "/cygdrive" (or other mountpoint) from mount=`mount -p`
  27. mountpoint=${mountpoint#*/}
  28. mountpoint=/${mountpoint%%[!A-Za-z0-9_]*}
  29. mountpoint=${mountpoint%/}
  30. args=""
  31. up=""
  32. if test "${prog}" = "-up"; then
  33. up=1
  34. prog=${1}
  35. shift
  36. fi
  37. process=1
  38. # Convert the mountpoint in parameters to Win32 filenames
  39. # For instance: /cygdrive/c/foo -> c:/foo
  40. for i in "${@}"
  41. do
  42. if test "${i}" = "-wrap"; then
  43. process=1
  44. else
  45. if test "${i}" = "-nowrap"; then
  46. process=
  47. else
  48. if test -n "${process}"; then
  49. if test -n "${up}"; then
  50. pathname=${i#-I[a-zA-Z]:/}
  51. if ! test "${pathname}" = "${i}"; then
  52. no_i=${i#-I}
  53. driveletter=${no_i%%:*}
  54. i=-I${mountpoint}/${driveletter}/${pathname}
  55. fi
  56. else
  57. eval 'leader=${i%%'${mountpoint}'/[a-zA-Z]/*}'
  58. if ! test "${leader}" = "${i}"; then
  59. eval 'pathname=${i#'${leader}${mountpoint}'/[a-zA-Z]/}'
  60. eval 'no_mountpoint=${i#'${leader}${mountpoint}'/}'
  61. driveletter=${no_mountpoint%%/*}
  62. i=${leader}${driveletter}:/${pathname}
  63. fi
  64. fi
  65. fi
  66. args="${args} ${i}"
  67. fi
  68. fi
  69. done
  70. exec $prog $args