I need a simple script to call gcc but I've got a long list of libraries that I need to pass to it in a directory who's path has a space on it.
In place of gcc for testing my script I've used:
#!/bin/bash
for var in "$@"
do
echo "$var"
done
This is one of the umpteen attempts I've tried:
#!/bin/bash
LIBDIR="lib dir"
LIBS=
LIBS+="lib1 "
LIBS+="lib2 "
CMD="./debug.sh "
for LIB in $LIBS
do
CMD+="-I ${LIBDIR}/${LIB} "
done
${CMD}
exit
Obviously the problem is that bash cannot tell which spaces are meant to separate the arguments and which are not, but no matter how I place quotes or backslashes I cannot figure out how to 'quote' some of the spaces and not the others.