So I have this:
export ti_arg='';
if [[ -t 1 ]] ; then
# allow us to kill container if attached to terminal
export ti_arg='-ti'
fi
(
cd "$(dirname "$BASH_SOURCE")"
docker build <...> '.'
docker run "$ti_arg" --rm "test-$commit_id"
)
the problem is that even if $ti_arg is empty, the shell still sees it as an argument, and I get:
docker : invalid reference format
The only solution I can think of is and if/else to run basically the same docker command except for that one arg, or to find some pass through argument that I can use with docker, like this:
export ti_arg='--noop';
if [[ -t 1 ]] ; then
# allow us to kill container if attached to terminal
export ti_arg='-ti'
fi
anyone have a good solution? I guess a CLI design would always provide a --noop
flag for this use case ...now go update all your own CLI tools
docker run
will see the '' empty string as the name of the image to run – Alexander Mills Apr 30 '20 at 21:16export
all your variables: only the vars that spawned programs require need to be exported. – glenn jackman Apr 30 '20 at 22:32