Skip to content

Commit fefe273

Browse files
committedMay 7, 2020
shell_helpers: force_oneline actually forces oneline cd and env vars
1 parent 695bdaa commit fefe273

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
 

‎shell_helpers.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,14 @@ def cmd_to_string(
140140
out = []
141141
if extra_env is None:
142142
extra_env = {}
143+
preffix_arr = []
143144
if cwd is not None:
144-
out.append('cd {} &&'.format(shlex.quote(cwd)))
145+
preffix_arr.append('cd {} &&'.format(shlex.quote(cwd)))
146+
extra_env2 = extra_env.copy()
145147
if extra_paths is not None:
146-
out.append('PATH="{}:${{PATH}}"'.format(':'.join(extra_paths)))
147-
for key in extra_env:
148-
out.append('{}={}'.format(shlex.quote(key), shlex.quote(extra_env[key])))
148+
extra_env2['PATH'] = '{}:"${{PATH}}"'.format(shlex.quote(':'.join(extra_paths)))
149+
for key in extra_env2:
150+
preffix_arr.append('{}={}'.format(shlex.quote(key), shlex.quote(extra_env2[key])))
149151
cmd_quote = []
150152
newline_count = 0
151153
for arg in cmd:
@@ -164,6 +166,10 @@ def cmd_to_string(
164166
)
165167
if not x
166168
]
169+
if self.force_oneline(force_oneline):
170+
cmd_quote = [' '.join(preffix_arr + cmd_quote)]
171+
else:
172+
cmd_quote = preffix_arr + cmd_quote
167173
out.extend(cmd_quote)
168174
if stdin_path is not None:
169175
out.append('< {}'.format(shlex.quote(stdin_path)))

0 commit comments

Comments
 (0)
Please sign in to comment.