Answer the question
In order to leave comments, you need to log in
How does bash expansion work?
Simplified version of the question.
Let there be two commands, one generates a set of parameters for the second. How to compose them?
I do:
$ cat args.sh
Q="quoted arg"
U="unquoted arg"
echo -n "first \"second $Q\" $U"
$ cat multiarg.sh
echo "1st: $1"
echo "2nd: $2"
echo "3rd: $3"
$ ./multiarg.sh $(./args.sh)
1st: first
2nd: "second
3rd: quoted
1st: first
2nd: second quoted arg
3rd: unquoted
$ cat ~/.local/bin/dcrm
#/bin/bash
echo "-it -v \"$PWD\":/pr -w /pr -u $(id -u):$(id -g)"
$ dcrm
-it -v "/disk/Projects/graph":/pr -w /pr -u 1000:1000
$ docker run --rm $(dcrm) hello-world
docker: Error response from daemon: create "/disk/Projects/graph": "\"/disk/Projects/graph\"" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.
docker run --rm -it -v "/disk/Projects/graph":/pr -w /pr -u 1000:1000 hello-world
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question