lnav/test/test_shlexer.sh

159 lines
2.1 KiB
Bash
Raw Normal View History

#! /bin/bash
export FOO='bar'
export DEF='xyz'
2015-12-19 06:54:32 +00:00
run_test ./drive_shlexer '$FOO'
2015-12-25 20:03:44 +00:00
check_output_ws "var ref" <<EOF
\$FOO
ref ^--^
eval -- bar
2015-12-25 20:03:44 +00:00
split:
0 -- bar
EOF
run_test ./drive_shlexer '${FOO}'
2015-12-25 20:03:44 +00:00
check_output_ws "var ref" <<EOF
\${FOO}
qrf ^----^
eval -- bar
2015-12-25 20:03:44 +00:00
split:
0 -- bar
EOF
2015-12-19 06:54:32 +00:00
run_test ./drive_shlexer '\a'
2015-12-25 20:03:44 +00:00
check_output_ws "escape" <<EOF
\a
esc ^^
eval -- a
2015-12-25 20:03:44 +00:00
split:
0 -- a
EOF
run_test ./drive_shlexer '\'
2015-12-25 20:03:44 +00:00
check_output_ws "error" <<EOF
\\
err ^
EOF
2015-12-19 06:54:32 +00:00
run_test ./drive_shlexer "'abc'"
2015-12-25 20:03:44 +00:00
check_output_ws "single" <<EOF
'abc'
sst ^
sen ^
eval -- abc
2015-12-25 20:03:44 +00:00
split:
0 -- abc
EOF
2015-12-19 06:54:32 +00:00
run_test ./drive_shlexer '"def"'
2015-12-25 20:03:44 +00:00
check_output_ws "double" <<EOF
"def"
dst ^
den ^
eval -- def
2015-12-25 20:03:44 +00:00
split:
0 -- def
EOF
run_test ./drive_shlexer '"'"'"'"'
2015-12-25 20:03:44 +00:00
check_output_ws "double with single" <<EOF
"'"
dst ^
den ^
eval -- '
2015-12-25 20:03:44 +00:00
split:
0 -- '
EOF
run_test ./drive_shlexer "'"'"'"'"
2015-12-25 20:03:44 +00:00
check_output_ws "single with double" <<EOF
'"'
sst ^
sen ^
eval -- "
2015-12-25 20:03:44 +00:00
split:
0 -- "
EOF
2015-12-19 06:54:32 +00:00
run_test ./drive_shlexer '"abc $DEF 123"'
2015-12-25 20:03:44 +00:00
check_output_ws "double w/ref" <<EOF
"abc \$DEF 123"
dst ^
ref ^--^
den ^
eval -- abc xyz 123
2015-12-25 20:03:44 +00:00
split:
0 -- abc xyz 123
EOF
run_test ./drive_shlexer '"abc ${DEF} 123"'
2015-12-25 20:03:44 +00:00
check_output_ws "double w/quoted-ref" <<EOF
"abc \${DEF} 123"
dst ^
qrf ^----^
2015-12-25 20:03:44 +00:00
den ^
eval -- abc xyz 123
2015-12-25 20:03:44 +00:00
split:
0 -- abc xyz 123
EOF
2015-12-19 06:54:32 +00:00
run_test ./drive_shlexer "'abc \$DEF 123'"
2015-12-25 20:03:44 +00:00
check_output_ws "single w/ref" <<EOF
'abc \$DEF 123'
sst ^
sen ^
eval -- abc \$DEF 123
2015-12-25 20:03:44 +00:00
split:
0 -- abc \$DEF 123
EOF
2015-12-25 20:03:44 +00:00
run_test ./drive_shlexer 'abc $DEF 123'
2015-12-25 20:03:44 +00:00
check_output_ws "unquoted" <<EOF
abc \$DEF 123
wsp ^
ref ^--^
2015-12-25 20:03:44 +00:00
wsp ^^
eval -- abc xyz 123
split:
0 -- abc
1 -- xyz
2 -- 123
EOF
run_test ./drive_shlexer '~ foo'
check_output_ws "tilde" <<EOF
~ foo
til ^
wsp ^
eval -- ../test foo
split:
0 -- ../test
1 -- foo
EOF
2020-09-11 04:19:23 +00:00
run_test ./drive_shlexer '~nonexistent/bar baz'
check_output_ws "tilde with username" <<EOF
~nonexistent/bar baz
til ^----------^
wsp ^
eval -- ~nonexistent/bar baz
split:
0 -- ~nonexistent/bar
1 -- baz
EOF