I have the following simple script:
#!/usr/bin/env bash
ARG_A="test -b"
CMD="./script.sh"
Inside that script, I want to assemble a command ./script.sh -a $ARG_A
(i.e ./script.sh -a 'test -b'
in this example). Argument for -a
might be sourced from a different file, thats why I put it into a separate variable ARG_A
.
If I execute the command via
$CMD -a "$ARG_A"
it works as expected. However, I want to put this into CMD
so I can get the same result just via
$CMD
I tried different things like
ARG_A=(-a "$ARG_A")
CMD="$CMD ${ARG_A[@]}"
but it doesn't work. Any ideas?
Thanks!