Skip to content

Commit

Permalink
[New] parse: Add syntax support for duplicating input file descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
lkoskela authored and ljharb committed Jan 29, 2023
1 parent c5549fc commit 216b198
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// '<(' is process substitution operator and
// can be parsed the same as control operator
var CONTROL = '(?:' + [
'\\|\\|', '\\&\\&', ';;', '\\|\\&', '\\<\\(', '>>', '>\\&', '[&;()|<>]'
'\\|\\|', '\\&\\&', ';;', '\\|\\&', '\\<\\(', '>>', '>\\&', '<\\&', '[&;()|<>]'
].join('|') + ')';
var META = '|&;()<> \\t';
var BAREWORD = '(\\\\[\'"' + META + ']|[^\\s\'"' + META + '])+';
Expand Down
13 changes: 13 additions & 0 deletions test/op.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ test('double operators', function (t) {
t.end();
});

test('duplicating input file descriptors', function (t) {
// duplicating stdout to file descriptor 3
t.same(parse('beep 3<&1'), ['beep', '3', { op: '<&' }, '1']);

// duplicating stdout to file descriptor 0, i.e. stdin
t.same(parse('beep <&1'), ['beep', { op: '<&' }, '1']);

// closes stdin
t.same(parse('beep <&-'), ['beep', { op: '<&' }, '-']);

t.end();
});

test('glob patterns', function (t) {
t.same(
parse('tap test/*.test.js'),
Expand Down

0 comments on commit 216b198

Please sign in to comment.