fix empty string parsing for the command (#6074)

Fixes #6072
This commit is contained in:
Saugat Pachhai
2021-05-28 06:51:27 +00:00
committed by GitHub
parent 63dba45c14
commit a74855b9f7
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -113,8 +113,11 @@ def parse_cmd(commands: List[str]) -> str:
"""
def quote_argument(arg: str):
should_quote = " " in arg and '"' not in arg
return f'"{arg}"' if should_quote else arg
if not arg:
return '""'
if " " in arg and '"' not in arg:
return f'"{arg}"'
return arg
if len(commands) < 2:
return " ".join(commands)
+1
View File
@@ -10,6 +10,7 @@ from dvc.command.stage import CmdStageAdd
(["echo", "foo", "bar"], "echo foo bar"),
(["echo", '"foo bar"'], 'echo "foo bar"'),
(["echo", "foo bar"], 'echo "foo bar"'),
(["cmd", "--flag", ""], 'cmd --flag ""'),
],
)
def test_stage_add(mocker, dvc, command, parsed_command):