Skip to content

Commit 190e236

Browse files
committed
[Tests] quote: pin that a backslash with whitespace is not doubled in single quotes (#14)
1 parent a04d475 commit 190e236

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎test/quote.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ test('quote tilde (escapes leading ~ to prevent shell tilde-expansion)', functio
4242
t.end();
4343
});
4444

45+
test('backslash with whitespace is not doubled in single quotes (#14)', function (t) {
46+
t.equal(quote(['foo \\ bar']), "'foo \\ bar'", 'a backslash between spaces stays a single literal backslash');
47+
t.equal(quote(['foo \\\\ bar']), "'foo \\\\ bar'", 'a double backslash is preserved, not quadrupled');
48+
t.equal(quote(['foo\\\nbar']), "'foo\\\nbar'", 'a backslash before a newline is preserved');
49+
t.end();
50+
});
51+
4552
test('escapes shell-special characters conservatively (issue #11)', function (t) {
4653
t.equal(quote(['make', 'CFLAGS=-DRELEASE']), 'make CFLAGS\\=-DRELEASE', 'escapes = so a leading word is not read as an assignment');
4754
t.equal(quote(['a@b']), 'a\\@b', 'escapes @ (zsh globbing)');

0 commit comments

Comments
 (0)