3f133b96b5cbe82b1bcfc4c39bb77382bd778444
[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     eval "${@}"
11     return $?
12   fi
13
14   declare -a darc_commands=()
15 #hmmm: may need the serious slash treatment.
16
17   for i in "$@"; do
18     if [[ "$i" =~ ^-[a-zA-z][/\"].* ]]; then
19       flag="${i:0:2}"
20       filename="$(unix_to_dos_path ${i:2})"
21 #echo "first two chars are $flag"
22 #echo "last after that are $filename"
23       recombined="$flag$filename"
24 #echo combined flag and file is $recombined
25       darc_commands+=("$recombined")
26     else 
27       darc_commands+=($(unix_to_dos_path $i))
28     fi
29   done
30
31   declare -a real_commands=()
32   for i in "${darc_commands[@]}"; do
33     real_commands+=($(echo $i | sed -e 's/\\/\\\\/g'))
34   done
35
36 #temp!
37   echo commands are now:
38   for i in "${real_commands[@]}"; do
39     echo -n "$i "
40   done
41   echo
42 #end temp
43
44   # now actually run the chewed command.
45   cmd /c "${real_commands[@]}"
46 }
47
48 dossify_and_run_commands "$@"
49