Skip to content

Commit 216b198

Browse files
lkoskelaljharb
authored andcommitted
[New] parse: Add syntax support for duplicating input file descriptors
1 parent c5549fc commit 216b198

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// '<(' is process substitution operator and
44
// can be parsed the same as control operator
55
var CONTROL = '(?:' + [
6-
'\\|\\|', '\\&\\&', ';;', '\\|\\&', '\\<\\(', '>>', '>\\&', '[&;()|<>]'
6+
'\\|\\|', '\\&\\&', ';;', '\\|\\&', '\\<\\(', '>>', '>\\&', '<\\&', '[&;()|<>]'
77
].join('|') + ')';
88
var META = '|&;()<> \\t';
99
var BAREWORD = '(\\\\[\'"' + META + ']|[^\\s\'"' + META + '])+';

test/op.js

+13
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ test('double operators', function (t) {
6969
t.end();
7070
});
7171

72+
test('duplicating input file descriptors', function (t) {
73+
// duplicating stdout to file descriptor 3
74+
t.same(parse('beep 3<&1'), ['beep', '3', { op: '<&' }, '1']);
75+
76+
// duplicating stdout to file descriptor 0, i.e. stdin
77+
t.same(parse('beep <&1'), ['beep', { op: '<&' }, '1']);
78+
79+
// closes stdin
80+
t.same(parse('beep <&-'), ['beep', { op: '<&' }, '-']);
81+
82+
t.end();
83+
});
84+
7285
test('glob patterns', function (t) {
7386
t.same(
7487
parse('tap test/*.test.js'),

0 commit comments

Comments
 (0)