2015-12-19 06:39:27 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
export FOO='bar'
|
|
|
|
export DEF='xyz'
|
|
|
|
|
2015-12-19 06:54:32 +00:00
|
|
|
run_test ./drive_shlexer '$FOO'
|
2015-12-19 06:39:27 +00:00
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "var ref" <<EOF
|
2015-12-19 06:39:27 +00:00
|
|
|
\$FOO
|
|
|
|
ref ^--^
|
|
|
|
eval -- bar
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- bar
|
2015-12-19 06:39:27 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-24 11:35:02 +00:00
|
|
|
run_test ./drive_shlexer '${FOO}'
|
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "var ref" <<EOF
|
2015-12-24 11:35:02 +00:00
|
|
|
\${FOO}
|
|
|
|
qrf ^----^
|
|
|
|
eval -- bar
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- bar
|
2015-12-24 11:35:02 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-19 06:54:32 +00:00
|
|
|
run_test ./drive_shlexer '\a'
|
2015-12-19 06:39:27 +00:00
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "escape" <<EOF
|
2015-12-19 06:39:27 +00:00
|
|
|
\a
|
|
|
|
esc ^^
|
|
|
|
eval -- a
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- a
|
2015-12-19 06:39:27 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-24 11:35:02 +00:00
|
|
|
run_test ./drive_shlexer '\'
|
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "error" <<EOF
|
2015-12-24 11:35:02 +00:00
|
|
|
\\
|
|
|
|
err ^
|
|
|
|
EOF
|
|
|
|
|
2015-12-19 06:54:32 +00:00
|
|
|
run_test ./drive_shlexer "'abc'"
|
2015-12-19 06:39:27 +00:00
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "single" <<EOF
|
2015-12-19 06:39:27 +00:00
|
|
|
'abc'
|
|
|
|
sst ^
|
|
|
|
sen ^
|
|
|
|
eval -- abc
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- abc
|
2015-12-19 06:39:27 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-19 06:54:32 +00:00
|
|
|
run_test ./drive_shlexer '"def"'
|
2015-12-19 06:39:27 +00:00
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "double" <<EOF
|
2015-12-19 06:39:27 +00:00
|
|
|
"def"
|
|
|
|
dst ^
|
|
|
|
den ^
|
|
|
|
eval -- def
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- def
|
2015-12-19 06:39:27 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-24 11:35:02 +00:00
|
|
|
run_test ./drive_shlexer '"'"'"'"'
|
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "double with single" <<EOF
|
2015-12-24 11:35:02 +00:00
|
|
|
"'"
|
|
|
|
dst ^
|
|
|
|
den ^
|
|
|
|
eval -- '
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- '
|
2015-12-24 11:35:02 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
run_test ./drive_shlexer "'"'"'"'"
|
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "single with double" <<EOF
|
2015-12-24 11:35:02 +00:00
|
|
|
'"'
|
|
|
|
sst ^
|
|
|
|
sen ^
|
|
|
|
eval -- "
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- "
|
2015-12-24 11:35:02 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-19 06:54:32 +00:00
|
|
|
run_test ./drive_shlexer '"abc $DEF 123"'
|
2015-12-19 06:39:27 +00:00
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "double w/ref" <<EOF
|
2015-12-19 06:39:27 +00:00
|
|
|
"abc \$DEF 123"
|
|
|
|
dst ^
|
|
|
|
ref ^--^
|
|
|
|
den ^
|
|
|
|
eval -- abc xyz 123
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- abc xyz 123
|
2015-12-19 06:39:27 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-24 11:35:02 +00:00
|
|
|
run_test ./drive_shlexer '"abc ${DEF} 123"'
|
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "double w/quoted-ref" <<EOF
|
2015-12-24 11:35:02 +00:00
|
|
|
"abc \${DEF} 123"
|
|
|
|
dst ^
|
|
|
|
qrf ^----^
|
2015-12-25 20:03:44 +00:00
|
|
|
den ^
|
2015-12-24 11:35:02 +00:00
|
|
|
eval -- abc xyz 123
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- abc xyz 123
|
2015-12-24 11:35:02 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-19 06:54:32 +00:00
|
|
|
run_test ./drive_shlexer "'abc \$DEF 123'"
|
2015-12-19 06:39:27 +00:00
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "single w/ref" <<EOF
|
2015-12-19 06:39:27 +00:00
|
|
|
'abc \$DEF 123'
|
|
|
|
sst ^
|
|
|
|
sen ^
|
|
|
|
eval -- abc \$DEF 123
|
2015-12-25 20:03:44 +00:00
|
|
|
split:
|
|
|
|
0 -- abc \$DEF 123
|
2015-12-19 06:39:27 +00:00
|
|
|
EOF
|
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
run_test ./drive_shlexer 'abc $DEF 123'
|
2015-12-19 06:39:27 +00:00
|
|
|
|
2015-12-25 20:03:44 +00:00
|
|
|
check_output_ws "unquoted" <<EOF
|
|
|
|
abc \$DEF 123
|
|
|
|
wsp ^
|
2015-12-19 06:39:27 +00:00
|
|
|
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
|
2015-12-19 06:39:27 +00:00
|
|
|
EOF
|