2

When I run this command:

https_proxy=http://myproxy.com/ aws [aws-param]

the proxy is picked up by the aws command line tool.

However - when I do this:

https_proxy=http://myproxy.com/ 
aws [aws-param]

the aws command doesn't pick up the proxy.

To me, they're the same from a unix point of view. Is this something about the way python reads environment variables?

My question is: Why does an inline variable definition work but a previous line does not for an aws command?

hawkeye
  • 485

1 Answers1

3

They’re not the same from a Unix point of view (or rather, from the shell’s point of view).

https_proxy=http://myproxy.com/ aws [aws-param]

defines the https_proxy variable explicitly for the aws command; the shell copies it to the aws process’s environment, and aws sees it.

https_proxy=http://myproxy.com/ 
aws [aws-param]

defines the variable in the shell’s environment, but because it’s not exported, the shell doesn’t copy it to the aws process’s environment.

The equivalent (from aws’s point of view) is actually

https_proxy=http://myproxy.com/ 
export https_proxy
aws [aws-param]

See What is this Bash syntax: someVariable=someValue command for more details (and links to the documentation).

Stephen Kitt
  • 434,908