Skip to content

Commit

Permalink
Allow unmatched square-brackets in values (#782)
Browse files Browse the repository at this point in the history
Co-authored-by: George Hansper <[email protected]>
  • Loading branch information
georgehansper and George Hansper authored Dec 3, 2022
1 parent ff7e200 commit 187de8b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/augrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static char *nexttoken(struct command *cmd, char **line, bool path) {
if (nescaped == 0) {
if (*s == '[') nbracket += 1;
if (*s == ']') nbracket -= 1;
if (nbracket < 0) {
if (nbracket < 0 && path) {
ERR_REPORT(cmd, AUG_ECMDRUN, "unmatched [");
return NULL;
}
Expand Down
1 change: 1 addition & 0 deletions tests/root/var/tmp/test-quoted-strings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find this: ]][ )( . * $ / \
35 changes: 35 additions & 0 deletions tests/test-augtool/quoted-strings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#insert after /files/tmp/test-quoted-strings.txt/*[. =~ regexp('find.*')] 'found ['
commands="
set /files/var/tmp/test-quoted-strings.txt/01 '['
set /files/var/tmp/test-quoted-strings.txt/02 ']'
set /files/var/tmp/test-quoted-strings.txt/03 ']['
set /files/var/tmp/test-quoted-strings.txt/04 '[]'
set /files/var/tmp/test-quoted-strings.txt/05 '[]['
set /files/var/tmp/test-quoted-strings.txt/06 '[]]'
set /files/var/tmp/test-quoted-strings.txt/07 '('
set /files/var/tmp/test-quoted-strings.txt/08 ')'
set /files/var/tmp/test-quoted-strings.txt/09 '"\""'
insert 010 after /files/var/tmp/test-quoted-strings.txt/seq::*[.=~regexp('.*\]\]\[ \)\( .*')]
set /files/var/tmp/test-quoted-strings.txt/010 'found ]][ )('
insert 011 after /files/var/tmp/test-quoted-strings.txt/seq::*[.=~regexp('.*\\\..*')]
set /files/var/tmp/test-quoted-strings.txt/011 'found .'
"
lens=Simplelines.lns
file="/var/tmp/test-quoted-strings.txt"

diff='--- /var/tmp/test-quoted-strings.txt
+++ /var/tmp/test-quoted-strings.txt.augnew
@@ -1 +1,12 @@
find this: ]][ )( . * $ / \
+found .
+found ]][ )(
+[
+]
+][
+[]
+[][
+[]]
+(
+)
+"'

0 comments on commit 187de8b

Please sign in to comment.