Add a test for invalid regex variable names

Also apply some mild refactoring.
This commit is contained in:
ridiculousfish
2021-04-20 11:28:34 -07:00
parent 8e95bba25e
commit abd59c50b0
2 changed files with 26 additions and 12 deletions

View File

@@ -1,6 +1,10 @@
#RUN: %fish %s
# Tests for importing named regex groups as fish variables
# Invalid variable name?
string match --regex -q '(?<FISH_VERSION>.*)' -- derp
# CHECKERR: Modification of read-only variable "FISH_VERSION" is not allowed
# Capture first match
echo "hello world" | string match --regex -q -- '(?<words>[^ ]+) ?'
printf "%s\n" $words