updated from windows side and nearly working over there.
[feisty_meow.git] / scripts / generator / wrapdoze.sh
1 #!/bin/bash
2
3 source $FEISTY_MEOW_SCRIPTS/core/functions.sh
4
5 # for a windows build, this will replace any forward slashes
6 # and other cygwin notation with the appropriate dos style paths.
7 function dossify_and_run_commands()
8 {
9   if [ "$OS" != "Windows_NT" ]; then
10     # for non windows, just run the commands straight up.
11     eval "${@}"
12     return $?
13   fi
14
15   # force all slashes to be dossy.
16 #  export SERIOUS_SLASH_TREATMENT=true
17
18   declare -a darc_commands=()
19
20   for i in "$@"; do
21     if [[ "$i" =~ ^-[a-zA-z][/\"].* ]]; then
22       flag="${i:0:2}"
23       filename="$(unix_to_dos_path ${i:2})"
24 #echo "first two chars are $flag"
25 #echo "last after that are $filename"
26       recombined="$flag$filename"
27 #echo combined flag and file is $recombined
28       darc_commands+=("$recombined")
29     else 
30       darc_commands+=($(unix_to_dos_path $i))
31     fi
32   done
33
34   declare -a real_commands=()
35   for i in "${darc_commands[@]}"; do
36     real_commands+=($(echo $i | sed -e 's/\\/\\\\/g'))
37   done
38
39   if [ ! -z "$SHELL_DEBUG" ]; then
40     echo commands are now:
41     for i in "${real_commands[@]}"; do
42       echo -n "$i "
43     done
44     echo
45   fi
46
47   # now actually run the chewed command.
48   cmd /c "${real_commands[@]}"
49 }
50
51 dossify_and_run_commands "$@"
52