Skip to content

Commit 1c36f3f

Browse files
committed
[Tests] quote: pin conservative escaping of =, @, ^, ,, :, ! (#11)
1 parent e1c75cd commit 1c36f3f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎test/quote.js‎

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

45+
test('escapes shell-special characters conservatively (issue #11)', function (t) {
46+
t.equal(quote(['make', 'CFLAGS=-DRELEASE']), 'make CFLAGS\\=-DRELEASE', 'escapes = so a leading word is not read as an assignment');
47+
t.equal(quote(['a@b']), 'a\\@b', 'escapes @ (zsh globbing)');
48+
t.equal(quote(['a^b']), 'a\\^b', 'escapes ^ (zsh extendedglob, csh)');
49+
t.equal(quote(['a:b']), 'a\\:b', 'escapes :');
50+
t.equal(quote(['a,b']), 'a\\,b', 'escapes , (brace expansion)');
51+
t.equal(quote(['a!b']), 'a\\!b', 'escapes ! (history expansion / pipeline negation)');
52+
t.end();
53+
});
54+
4555
test('quote ops', function (t) {
4656
t.equal(quote(['a', { op: '|' }, 'b']), 'a \\| b');
4757
t.equal(

0 commit comments

Comments
 (0)