To keep it simple, at the top of my bash script is the following code
#!/bin/bash
#if no arguments passed
if [ -z "$1" ]; then
DEBUG='1>/dev/null'
else
DEBUG='1>&1'
fi
Then throughout the rest of the script are calls like this
echo Doing something here! $DEBUG
The point being if someone calls the script without arguments (./myScript.sh) it wont echo anything.
But if they do pass in a parameter (./myScript.sh whathaveyou) the echo statements should work normally.
Unfortunately, however echo Doing something here! $DEBUG is being evaluated as
echo Doing something here! "1>&1"
instead of
echo Doing something here! 1>&1
How can I make this work?