I have a small bash script build1c.sh .
if [ "$1" = "" ]; then
echo "You must give a .c file to compile."
exit 1
fi
cfile=$1
stem=${cfile%.*}
set -o verbose
gcc -c -g -Wall $cfile
gcc -o $stem $stem.o common.o reentrant.o -lssl -lcrypto
set +o verbose # optional here
The intention is to only echo the gcc commands being executed. I work to some extend. When I call build1c.sh client2.c , I see output
gcc -c -g -Wall $cfile
gcc -o $stem $stem.o common.o reentrant.o -lssl -lcrypto
set +o verbose # optional here
Still wacky, right? Those var reference($cfile, $stem) do not get their final form, so the echoing becomes pretty useless.
You know, what I like to see is
gcc -c -g -Wall client2.c
gcc -o client2 client2.o common.o reentrant.o -lssl -lcrypto
Is there correct and concise way to address this?
BTW: Minor request: Can I suppress the echoing of set +o verbose itself?
Replace
set -o verbosewithset -x