expand env before run script

Signed-off-by: Frost Ming <mianghong@gmail.com>
This commit is contained in:
Frost Ming
2018-11-17 22:50:04 +08:00
parent 32f5d85b0b
commit 6901eae31d
3 changed files with 13 additions and 2 deletions
+1
View File
@@ -0,0 +1 @@
Environment variables are expanded correctly before running scripts on POSIX.
+4 -2
View File
@@ -2262,7 +2262,7 @@ def do_run_nt(script):
def do_run_posix(script, command):
command_path = system_which(script.command)
command_path = system_which(os.path.expandvars(script.command))
if not command_path:
if project.has_script(command):
click.echo(
@@ -2287,7 +2287,9 @@ def do_run_posix(script, command):
err=True,
)
sys.exit(1)
os.execl(command_path, command_path, *script.args)
os.execl(
command_path, command_path, *[os.path.expandvars(arg) for arg in script.args]
)
def do_run(command, args, three=None, python=False, pypi_mirror=None):
+8
View File
@@ -1,6 +1,7 @@
import os
from pipenv.project import Project
from pipenv.utils import temp_environ
import pytest
@@ -27,6 +28,7 @@ printfoo = "python -c \"print('foo')\""
notfoundscript = "randomthingtotally"
appendscript = "cmd arg1"
multicommand = "bash -c \"cd docs && make html\""
scriptwithenv = "echo $HELLO"
""")
c = p.pipenv('install')
assert c.return_code == 0
@@ -52,3 +54,9 @@ multicommand = "bash -c \"cd docs && make html\""
script = project.build_script('appendscript', ['a', 'b'])
assert script.command == 'cmd'
assert script.args == ['arg1', 'a', 'b']
with temp_environ():
os.environ['HELLO'] = 'WORLD'
c = p.pipenv("run scriptwithenv")
assert c.ok
assert c.out.strip() == "WORLD"