From 0e172361a894213b1c1ae4332ac00c7be2eb8df0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 6 Aug 2018 11:09:45 -0700 Subject: [PATCH] Support #*# operator in variable expansions Fixes #10 --- corpus/literals.txt | 2 ++ src/scanner.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/corpus/literals.txt b/corpus/literals.txt index d0a9e9e..33036fb 100644 --- a/corpus/literals.txt +++ b/corpus/literals.txt @@ -56,6 +56,7 @@ echo $# $* $@ Variable expansions ============================= +echo ${var1#*#} echo ${!abc} echo ${abc} echo ${abc:-def} @@ -66,6 +67,7 @@ echo ${abc: --- (program + (command (command_name (word)) (expansion (variable_name) (word))) (command (command_name (word)) (expansion (variable_name))) (command (command_name (word)) (expansion (variable_name))) (command (command_name (word)) (expansion (variable_name) (word))) diff --git a/src/scanner.cc b/src/scanner.cc index f3bda14..ff06efc 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -98,6 +98,7 @@ struct Scanner { lexer->lookahead == '&' || lexer->lookahead == '|' || lexer->lookahead == '`' || + lexer->lookahead == '#' || (lexer->lookahead == '}' && valid_symbols[CLOSING_BRACE]) || (lexer->lookahead == ']' && valid_symbols[CLOSING_BRACKET]) )) {