I have a script like this:
mkdir "$test"
If $test
is empty, as with nothing then touch will complain with this:
touch: cannot touch '': No such file or directory
If I remove the "
then I get the behavior I'm expecting mkdir: missing operand
.
The issue is If I ever have filenames with spaces in $test it will break my script. I need to do it in a way that $test
can be empty or have spaces in it, and do not mess with my command either way.
In my real script the command line I'm using should just ignore $test
if it's empty like it happens when not quoted, but need to work with spaces too. The issue is this ''
stuff that appears in my command line.