Allow file redirects on while statements

This commit is contained in:
Max Brunsfeld 2018-02-28 16:28:30 -08:00
parent 6f81608535
commit 86c5561ba8
2 changed files with 24 additions and 1 deletions

View File

@ -16,6 +16,24 @@ done
(command (command_name (word)) (word)) (command (command_name (word)) (word))
(command (command_name (word)) (word))))) (command (command_name (word)) (word)))))
====================================
While statements with IO redirects
====================================
while read line; do
echo $line
done < <(cat file)
---
(program
(while_statement
(command (command_name (word)) (word))
(do_group
(command (command_name (word)) (simple_expansion (variable_name))))
(file_redirect (process_substitution
(command (command_name (word)) (word))))))
==================================== ====================================
For statements For statements
==================================== ====================================

View File

@ -78,7 +78,12 @@ module.exports = grammar({
while_statement: $ => seq( while_statement: $ => seq(
'while', 'while',
$._terminated_statement, $._terminated_statement,
$.do_group $.do_group,
repeat(choice(
$.file_redirect,
$.heredoc_redirect,
$.herestring_redirect
))
), ),
do_group: $ => seq( do_group: $ => seq(