updates getting us closer to working on windows. added a highly speculative implemen...
[feisty_meow.git] / scripts / generator / wrapdoze.sh
1 #!/bin/bash
2
3 source $FEISTY_MEOW_SCRIPTS/core/functions.sh
4
5 function dossify_and_run_commands()
6 {
7   # we only mess with the command line on windows...
8   if [ "$OS" != "Windows_NT" ]; then
9     # for non windows, just run the commands straight up.
10     $*
11     return $?
12   fi
13
14   declare -a darc_commands=()
15
16   for i in "$@"; do
17     if [[ "$i" =~ ^-[a-zA-z][/\"].* ]]; then
18       flag="${i:0:2}"
19       filename="$(unix_to_dos_path ${i:2})"
20 #echo "first two chars are $flag"
21 #echo "last after that are $filename"
22       recombined="$flag$filename"
23 #echo combined flag and file is $recombined
24       darc_commands+=("$recombined")
25     else 
26       darc_commands+=($(unix_to_dos_path $i))
27     fi
28   done
29
30   declare -a real_commands=()
31   for i in "${darc_commands[@]}"; do
32     real_commands+=($(echo $i | sed -e 's/\\/\\\\/g'))
33   done
34
35 #temp!
36   echo commands are now:
37   for i in "${real_commands[@]}"; do
38     echo -n "$i "
39   done
40   echo
41 #end temp
42
43   # now actually run the chewed command.
44   cmd /c "${real_commands[@]}"
45 }
46
47 dossify_and_run_commands "$@"
48