I am writing a basic script that has something like this:
LOG_COMMAND=">/tmp/something.log 2>&1"
if [ "${VERBOSE}" == "y" ]; then
LOG_COMMAND="2>&1 | tee /tmp/something.log"
fi
The problem is that when I use the LOG_COMMAND
variable in my script it gets wrapped with single quotes. For example:
set -v
docker build -t test:test . ${LOG_COMMAND}
set +v
I get the following output:
$ /bin/bash testing.sh -v
+ docker build -t test:test . '2>&1' '|' tee /tmp/something.log
"docker build" requires exactly 1 argument.
See 'docker build --help'.
How can I prevent the single quotes from being included?