'How can I export a command that has quotes in it? Im getting an error when I try to nest single quotes within double quote
I am attempting to add this to export in my profile
export CLI ='docker-compose exec cardano-node sh -c "CARDANO_NODE_SOCKET_PATH=/ipc/node.socket cardano-cli"'
This command works with no issue from the command line docker-compose exec cardano-node sh -c "CARDANO_NODE_SOCKET_PATH=/ipc/node.socket cardano-cli"
I tried it placing it in quote a number of ways and I keep getting the following error
cardano-cli": -c: line 0: unexpected EOF while looking for matching `"' cardano-cli": -c: line 1: syntax error: unexpected end of file
What's the deal here?
Solution 1:[1]
docker-compose exec takes a -e option to set environment variables. If you use that option, you don't need the sh -c wrapper, since you are just running a simple command, and this removes a layer of quotes.
export CLI=`docker-compose exec -e CARDANO_NODE_SOCKET_PATH=/ipc/node.socket cardano-node cardano-cli`
docker-compose exec will also get the environment variables from the docker-compose.yml file, so if you declare the variables there
services:
cardano-node:
environment:
- CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
you don't have to repeat them in docker-compose exec at all
export CLI=`docker-compose exec cardano-node cardano-cli`
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Maze |
