I'm writing a Bash called "NewProject" that creates a second Bash script called "compile". Both scripts must be able to take arguments as input. My problem is that I can not write "$1" into the compile script - this simply copies the contents of NewProject's first argument into the compile script. This is the part of the NewProject script that creates the compile script.
echo "#!/bin/bash" > $1/compile
echo "
if [[ -z '$1' ]];
then
echo "You are missing file names. Type in: compile -o executable files."
exit 1
fi" >> $1/compile
chmod u+x $1/compile
And here is output from a test run of the NewProject script.
#!/bin/bash
if [[ -z 'testproject4' ]];
then
echo You are missing file names. Type in: compile -o executable files.
exit 1
fi
How can I change the NewProject script so that instead of 'testproject4', the compile script contains '$1'?