Make string syntax error location a bit more precise

String tokens are subdivided by command substitutions. Some syntax errors
can occur in the gap between two command substitutions. Make the caret point
to the start of that gap, instead of the token start.
This commit is contained in:
Johannes Altmanninger
2022-04-03 16:29:13 +02:00
parent e717b13e75
commit 4b5b56452b
2 changed files with 7 additions and 2 deletions

View File

@@ -39,6 +39,11 @@ $fish -c 'echo "unfinished "$(subshell' 2>| string replace -r '.*' '<$0>'
# CHECK: <echo "unfinished "$(subshell>
# CHECK: < ^>
$fish -c 'echo "ok $(echo still ok)syntax error: \x"' 2>| string replace -r '.*' '<$0>'
# CHECK: <fish: Invalid token '"ok $(echo still ok)syntax error: \x"'>
# CHECK: <echo "ok $(echo still ok)syntax error: \x">
# CHECK: < ^>
echo "function error" >$TMPDIR/error.fish
$fish -c "set -g fish_function_path $(string escape $TMPDIR); error"
# CHECKERR: ~/temp/error.fish (line 1): Missing end to balance this function definition
@@ -47,6 +52,6 @@ $fish -c "set -g fish_function_path $(string escape $TMPDIR); error"
# CHECKERR: from sourcing file ~/temp/error.fish
# CHECKERR: source: Error while reading file '{{.*}}/error.fish'
# CHECKERR: fish: Unknown command: error
# CHECKERR: fish:
# CHECKERR: fish:
# CHECKERR: set -g fish_function_path {{.*}}; error
# CHECKERR: ^