diff --git a/tests/string.err b/tests/string.err index 4c6095d4f..98c1702b8 100644 --- a/tests/string.err +++ b/tests/string.err @@ -291,3 +291,6 @@ string repeat -l fakearg #################### # string match -r "a*b([xy]+)" abc abxc bye aaabyz kaabxz abbxy abcx caabxyxz + +#################### +# Check NUL diff --git a/tests/string.in b/tests/string.in index 78b85ea13..cfef38b68 100644 --- a/tests/string.in +++ b/tests/string.in @@ -329,4 +329,15 @@ or echo strings not converted to uppercase string upper -q ABC DEF and echo uppercasing a uppercase string did not fail as expected +logmsg 'Check NUL' +# Note: We do `string escape` at the end to make a `\0` literal visible. +printf 'a\0b' | string escape +printf 'a\0c' | string match -e 'a' | string escape +printf 'a\0d' | string split '' | string escape +printf 'a\0b' | string match -r '.*b$' | string escape +printf 'a\0b' | string replace b g | string escape +printf 'a\0b' | string replace -r b g | string escape +# TODO: These do not yet work! +# printf 'a\0b' | string match '*b' | string escape + exit 0 diff --git a/tests/string.out b/tests/string.out index 68f060419..7ff40deba 100644 --- a/tests/string.out +++ b/tests/string.out @@ -422,3 +422,14 @@ bxy xy aabxyx xyx + +#################### +# Check NUL +a\x00b +a\x00c +a +\x00 +d +a\x00b +a\x00g +a\x00g