mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-04 23:05:21 +02:00
143 lines
2.6 KiB
Bash
Executable File
143 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
. ./Common
|
|
|
|
#
|
|
# Note that we have to escape things for the shell as well. In general,
|
|
# for any character C, \C becomes C. However, in the case of <<EOF ... EOF,
|
|
# \ is left as is if it doesn't precede a special character.
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
tst "substitutions: escape x in regexp" -R '*\\x' <<EOF
|
|
EOF
|
|
|
|
expect <<EOF
|
|
^.*\\x\$
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
tst "substitutions: escape * in regexp" -R '*\\*' <<EOF
|
|
EOF
|
|
|
|
expect <<EOF
|
|
^.*\*\$
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape . in regexp (implicit)" -R 'x.y' <<EOF
|
|
EOF
|
|
|
|
expect <<EOF
|
|
^x\.y\$
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape | in regexp" -R 'a\\\|b' <<EOF
|
|
EOF
|
|
|
|
expect <<EOF
|
|
^a\\|b\$
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape \\ in regexp" -R 'x\\\\y' <<EOF
|
|
EOF
|
|
|
|
expect <<EOF
|
|
^x\\\\y\$
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst_fail "substitutions: try to escape EOL in regexp" -R 'x\\' <<EOF
|
|
EOF
|
|
|
|
expect <<EOF
|
|
dummy:2: regexp ends with backslash
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape space in regexp (match)" -q '"x=a c"' <<EOF
|
|
!-s
|
|
y=a
|
|
x=a\ c { y=b }
|
|
EOF
|
|
|
|
expect <<EOF
|
|
y=b
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape space in regexp (no match)" -q '"x=a b"' <<EOF
|
|
!-s
|
|
y=a
|
|
x=a\ c { y=b }
|
|
EOF
|
|
|
|
expect <<EOF
|
|
y=a
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape \$ in value" -q <<EOF
|
|
!-s
|
|
x=y\\$
|
|
EOF
|
|
|
|
expect <<EOF
|
|
x=y\$
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape x in value" -q <<EOF
|
|
!-s
|
|
x=y\x
|
|
EOF
|
|
|
|
expect <<EOF
|
|
x=yx
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape space in value" -q <<EOF
|
|
!-s
|
|
x=x\ y
|
|
EOF
|
|
|
|
expect <<EOF
|
|
x=x y
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst "substitutions: escape \\ in value" -q <<EOF
|
|
!-s
|
|
x=a\\\\b
|
|
EOF
|
|
|
|
expect <<EOF
|
|
x=a\\b
|
|
EOF
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
tst_fail "substitutions: try to escape EOL in value" -q <<EOF
|
|
!-s
|
|
x=y\\
|
|
EOF
|
|
|
|
expect <<EOF
|
|
s:1: syntax error
|
|
EOF
|
|
|
|
###############################################################################
|