Xonsh: Question: How to set env for subprocess?

Created on 5 Dec 2017  路  5Comments  路  Source: xonsh/xonsh

Hi, thanks for this amazing project,

I've been searcing around the documentation, but I can't find an equivalence command for
HTTP_PROXY=myproxy curl www.google.com

With bash, I have an alias proxy="http_proxy=myproxy https_proxy=myproxy ", so that I can use proxy when I need to, e.g. proxy curl www.google.com. Is it possible with xonsh?

question

All 5 comments

Current working attempt

def proxy(args):
    def impl():
        $http_proxy='....' 
        $https_proxy=''....' 
        return args
    $[@(impl())]

aliases['proxy'] = proxy

# remove helper functions
del proxy

Hey @roxma -- you can take a look here for how to use the swap method on the env: http://xon.sh/bash_to_xsh.html?highlight=swap

You can also use the env command,

env HTTP_PROXY='....' mycommand

Thanks

Also, I'd happily welcome any PRs that add support for this, though I think we'd probably want the syntax $HTTP_PROXY='....' mycommand

I'd be happy with PRs to that effect with considerable test coverage.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

battaglia01 picture battaglia01  路  3Comments

OJFord picture OJFord  路  5Comments

jeremyherbert picture jeremyherbert  路  5Comments

blueray453 picture blueray453  路  5Comments

anki-code picture anki-code  路  4Comments