hush: implement $'str' bashism

function                                             old     new   delta
parse_dollar_squote                                    -     441    +441
encode_then_expand_vararg                            359     380     +21
parse_stream                                        2252    2271     +19
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 481/0)             Total: 481 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2021-07-26 15:29:13 +02:00
parent 05c5d745f7
commit b278d82c61
7 changed files with 138 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
a b
$'a\tb'
a
b c
def
a'b c"d e\f
a3b c3b e33f
a\80b c08b
a3b c30b
x y

View File

@@ -0,0 +1,8 @@
echo $'a\tb'
echo "$'a\tb'"
echo $'a\nb' $'c\nd''ef'
echo $'a\'b' $'c\"d' $'e\\f'
echo $'a\63b' $'c\063b' $'e\0633f'
echo $'a\80b' $'c\608b'
echo $'a\x33b' $'c\x330b'
echo $'x\x9y'

View File

@@ -0,0 +1,6 @@
strstrstrstrstrstrstrstrstrstrstrstrstrstrstrstrstr
strstrstrstrstrstrstrstrstrstrstrstrstrstrstrstrstr
80:\<5C>
81:\<5C>
82:\<5C>
Done:0

View File

@@ -0,0 +1,10 @@
# Embedded NULs
echo $'str\x00'strstrstrstrstrstrstrstrstrstrstrstrstrstrstrstr
echo $'str\000'strstrstrstrstrstrstrstrstrstrstrstrstrstrstrstr
# The chars after '\' are hex 0x80,81,82...
echo 80:$'\<5C>'
echo 81:$'\<5C>'
echo 82:$'\<5C>'
echo Done:$?

View File

@@ -0,0 +1 @@
B

View File

@@ -0,0 +1 @@
x=AB; echo "${x#$'\x41'}"