So, I wrote a simple script to convert sh
-style export key=value
statements to csh-style
setenv key value
for docker-machine env
.
#!/bin/sh
docker-machine env | sed -e 's/export/setenv/' -e 's/=/ /' -e '$d'
echo '# eval `docker-machine env`'
and it produces the following output
setenv DOCKER_TLS_VERIFY "1"
setenv DOCKER_HOST "tcp://<ipv4 address>:<port>"
setenv DOCKER_CERT_PATH "<HOME>/.docker/machine/machines/default"
setenv DOCKER_MACHINE_NAME "default"
# Run this command to configure your shell:
# eval `docker-machine env`
In my .tcshrc
I've bound this script to the alias docker-machine-env-csh
.
I can source the output of this script using a temporary variable just fine
% docker-machine-env-csh >! /tmp/csh && source /tmp/csh
However, I don't seem to be able to directly eval
the result of this alias
% eval `docker-machine-env-csh`
setenv: Too many arguments.
Or assign it to a variable in a way that preserves newlines.
% set a = `docker-machine-env-csh`
% printf "%s\n" "$a"
setenv ... setenv ... setenv ...
Although, weirdly printf "%s\n" `docker-machine-env-csh`
seems to insert a newline between every token.
% printf "%s\n" `docker-machine-env-csh`
setenv
...
...
setenv
...
...
How do I preserve newlines in tcsh
command substitution?