Skip to content

Commit 0fb001c

Browse files
committed
Quote empty strings. Fixes #84.
1 parent e7d9711 commit 0fb001c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn format_argument(arg: String) -> String {
116116
if arg.contains(quote_characters) {
117117
// if argument contains quotes then assume it is correctly quoted.
118118
return arg;
119-
} else if arg.contains(invalid_characters) {
119+
} else if arg.contains(invalid_characters) || arg.is_empty() {
120120
return format!("\"{}\"", arg);
121121
} else {
122122
return arg;
@@ -354,6 +354,11 @@ mod tests {
354354
assert_eq!(format_argument("--abc|def".to_string()), "\"--abc|def\"");
355355
}
356356

357+
#[test]
358+
fn format_empty_argument() {
359+
assert_eq!(format_argument("".to_string()), "\"\"");
360+
}
361+
357362
#[test]
358363
fn win_to_unix_path_trans() {
359364
env::remove_var("WSLGIT_MOUNT_ROOT");

0 commit comments

Comments
 (0)