You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first with sh.echo.bake("test1", _with=True) pushes /usr/bin/echo test1 onto the stack. The second with sh.echo.bake("test2", _with=True) pushes /usr/bin/echo test1 /usr/bin/echo test2 onto the stack. Then out = sh.echo("test3") comes along and we prepend both /usr/bin/echo test1 /usr/bin/echo test2 and /usr/bin/echo test1.
I think I have solution, but it seems too easy:
# aggregate any 'with' contextsforprependinget_prepend_stack():
pcall_args=prepend.call_args.copy()
# don't pass the 'with' call argpcall_args.pop("with", None)
call_args.update(pcall_args)
ifnotkwargs.get("_with", False):
cmd.extend(prepend.cmd)
Essentially, if this command is for a context, don't prepend anything to the command. We still need to update call_args or things like sh.contrib.sudo setting _in will get lost.
I'm happy to provide a PR, but want to make sure this is on the right track first.
The text was updated successfully, but these errors were encountered:
That makes sense. I think you are the first person to use nested _with :) If you can add the correct behavior and some tests, I will merge the PR. lmk if you run into issues.
When using nested contexts like the following:
I'd expect to get the following command:
What I actually get is:
It looks like the source of our problem is here:
sh/sh.py
Lines 1421 to 1428 in 4941fe0
The first
with sh.echo.bake("test1", _with=True)
pushes/usr/bin/echo test1
onto the stack. The secondwith sh.echo.bake("test2", _with=True)
pushes/usr/bin/echo test1 /usr/bin/echo test2
onto the stack. Thenout = sh.echo("test3")
comes along and we prepend both/usr/bin/echo test1 /usr/bin/echo test2
and/usr/bin/echo test1
.I think I have solution, but it seems too easy:
Essentially, if this command is for a context, don't prepend anything to the command. We still need to update
call_args
or things likesh.contrib.sudo
setting_in
will get lost.I'm happy to provide a PR, but want to make sure this is on the right track first.
The text was updated successfully, but these errors were encountered: