I'm working on a basic script to help my co-workers with compiler choices on Mac OS X. I have a working script, but there is room for much improvement.
Is it possible to use a response for, for example: which gcc
as an argument for if/then in the script, and how would this be structured?
Say that the script runs 'which gcc' and the response is /usr/bin/gcc (Xcode distribution), I would like to use this as follows:
which gcc
if "response"=/usr/bin/gcc; then
echo "Using Xcode gcc"
else
if "responce"=/usr/local/bin/gcc; then
echo "Using HPC gcc"
fi
fi
Right now the script is only checking for the presence of files and using that as arguments, but this isn't a particularly nice solution:
file=/usr/bin/gcc
if [ -f $file ] ; then
echo "Xcode gcc installed".............
Best regards
Gustaf
Is it possible to use a response for, for example: which gcc
as an argument for if/then in the script, and how would this be structured?
Say that the script runs 'which gcc' and the response is /usr/bin/gcc (Xcode distribution), I would like to use this as follows:
which gcc
if "response"=/usr/bin/gcc; then
echo "Using Xcode gcc"
else
if "responce"=/usr/local/bin/gcc; then
echo "Using HPC gcc"
fi
fi
Right now the script is only checking for the presence of files and using that as arguments, but this isn't a particularly nice solution:
file=/usr/bin/gcc
if [ -f $file ] ; then
echo "Xcode gcc installed".............
Best regards
Gustaf