pull some quoting fixes from oksh; original patch from Alexander Polakov
This commit is contained in:
parent
d5eda34c8b
commit
ec1bc74d41
151
check.t
151
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.613 2013/05/31 22:47:12 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.614 2013/06/01 00:15:55 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -2537,30 +2537,6 @@ expected-stdout:
|
|||||||
\END
|
\END
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
name: heredoc-quoting-unsubst
|
|
||||||
description:
|
|
||||||
Check for correct handling of quoted characters in
|
|
||||||
here documents without substitution (marker is quoted).
|
|
||||||
stdin:
|
|
||||||
foo=bar
|
|
||||||
cat <<-'EOF'
|
|
||||||
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
|
|
||||||
EOF
|
|
||||||
expected-stdout:
|
|
||||||
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
|
|
||||||
---
|
|
||||||
name: heredoc-quoting-subst
|
|
||||||
description:
|
|
||||||
Check for correct handling of quoted characters in
|
|
||||||
here documents with substitution (marker is not quoted).
|
|
||||||
stdin:
|
|
||||||
foo=bar
|
|
||||||
cat <<-EOF
|
|
||||||
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
|
|
||||||
EOF
|
|
||||||
expected-stdout:
|
|
||||||
x " \" \ \ $ $ baz `echo baz` bar $foo x
|
|
||||||
---
|
|
||||||
name: heredoc-tmpfile-1
|
name: heredoc-tmpfile-1
|
||||||
description:
|
description:
|
||||||
Check that heredoc temp files aren't removed too soon or too late.
|
Check that heredoc temp files aren't removed too soon or too late.
|
||||||
@ -2743,6 +2719,131 @@ expected-stdout:
|
|||||||
hi
|
hi
|
||||||
Left overs: *
|
Left overs: *
|
||||||
---
|
---
|
||||||
|
name: heredoc-quoting-unsubst
|
||||||
|
description:
|
||||||
|
Check for correct handling of quoted characters in
|
||||||
|
here documents without substitution (marker is quoted).
|
||||||
|
stdin:
|
||||||
|
foo=bar
|
||||||
|
cat <<-'EOF'
|
||||||
|
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
|
||||||
|
EOF
|
||||||
|
expected-stdout:
|
||||||
|
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
|
||||||
|
---
|
||||||
|
name: heredoc-quoting-subst
|
||||||
|
description:
|
||||||
|
Check for correct handling of quoted characters in
|
||||||
|
here documents with substitution (marker is not quoted).
|
||||||
|
stdin:
|
||||||
|
foo=bar
|
||||||
|
cat <<-EOF
|
||||||
|
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
|
||||||
|
EOF
|
||||||
|
expected-stdout:
|
||||||
|
x " \" \ \ $ $ baz `echo baz` bar $foo x
|
||||||
|
---
|
||||||
|
name: single-quotes-in-braces
|
||||||
|
description:
|
||||||
|
Check that single quotes inside unquoted {} are treated as quotes
|
||||||
|
stdin:
|
||||||
|
foo=1
|
||||||
|
echo ${foo:+'blah $foo'}
|
||||||
|
expected-stdout:
|
||||||
|
blah $foo
|
||||||
|
---
|
||||||
|
name: single-quotes-in-quoted-braces
|
||||||
|
description:
|
||||||
|
Check that single quotes inside quoted {} are treated as
|
||||||
|
normal char
|
||||||
|
stdin:
|
||||||
|
foo=1
|
||||||
|
echo "${foo:+'blah $foo'}"
|
||||||
|
expected-stdout:
|
||||||
|
'blah 1'
|
||||||
|
---
|
||||||
|
name: single-quotes-in-braces-nested
|
||||||
|
description:
|
||||||
|
Check that single quotes inside unquoted {} are treated as quotes,
|
||||||
|
even if that's inside a double-quoted command expansion
|
||||||
|
stdin:
|
||||||
|
foo=1
|
||||||
|
echo "$( echo ${foo:+'blah $foo'})"
|
||||||
|
expected-stdout:
|
||||||
|
blah $foo
|
||||||
|
---
|
||||||
|
name: single-quotes-in-brace-pattern
|
||||||
|
description:
|
||||||
|
Check that single quotes inside {} pattern are treated as quotes
|
||||||
|
stdin:
|
||||||
|
foo=1234
|
||||||
|
echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
|
||||||
|
expected-stdout:
|
||||||
|
1 1 1234 1234
|
||||||
|
---
|
||||||
|
name: single-quotes-in-heredoc-braces
|
||||||
|
description:
|
||||||
|
Check that single quotes inside {} in heredoc are treated
|
||||||
|
as normal char
|
||||||
|
stdin:
|
||||||
|
foo=1
|
||||||
|
cat <<EOM
|
||||||
|
${foo:+'blah $foo'}
|
||||||
|
EOM
|
||||||
|
expected-stdout:
|
||||||
|
'blah 1'
|
||||||
|
---
|
||||||
|
name: single-quotes-in-nested-braces
|
||||||
|
description:
|
||||||
|
Check that single quotes inside nested unquoted {} are
|
||||||
|
treated as quotes
|
||||||
|
stdin:
|
||||||
|
foo=1
|
||||||
|
echo ${foo:+${foo:+'blah $foo'}}
|
||||||
|
expected-stdout:
|
||||||
|
blah $foo
|
||||||
|
---
|
||||||
|
name: single-quotes-in-nested-quoted-braces
|
||||||
|
description:
|
||||||
|
Check that single quotes inside nested quoted {} are treated
|
||||||
|
as normal char
|
||||||
|
stdin:
|
||||||
|
foo=1
|
||||||
|
echo "${foo:+${foo:+'blah $foo'}}"
|
||||||
|
expected-stdout:
|
||||||
|
'blah 1'
|
||||||
|
---
|
||||||
|
name: single-quotes-in-nested-braces-nested
|
||||||
|
description:
|
||||||
|
Check that single quotes inside nested unquoted {} are treated
|
||||||
|
as quotes, even if that's inside a double-quoted command expansion
|
||||||
|
stdin:
|
||||||
|
foo=1
|
||||||
|
echo "$( echo ${foo:+${foo:+'blah $foo'}})"
|
||||||
|
expected-stdout:
|
||||||
|
blah $foo
|
||||||
|
---
|
||||||
|
name: single-quotes-in-nested-brace-pattern
|
||||||
|
description:
|
||||||
|
Check that single quotes inside nested {} pattern are treated as quotes
|
||||||
|
stdin:
|
||||||
|
foo=1234
|
||||||
|
echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
|
||||||
|
expected-stdout:
|
||||||
|
1 1 1234 1234
|
||||||
|
---
|
||||||
|
name: single-quotes-in-heredoc-nested-braces
|
||||||
|
description:
|
||||||
|
Check that single quotes inside nested {} in heredoc are treated
|
||||||
|
as normal char
|
||||||
|
stdin:
|
||||||
|
foo=1
|
||||||
|
cat <<EOM
|
||||||
|
${foo:+${foo:+'blah $foo'}}
|
||||||
|
EOM
|
||||||
|
expected-stdout:
|
||||||
|
'blah 1'
|
||||||
|
---
|
||||||
name: history-basic
|
name: history-basic
|
||||||
description:
|
description:
|
||||||
See if we can test history at all
|
See if we can test history at all
|
||||||
|
17
lex.c
17
lex.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: lex.c,v 1.46 2013/01/20 14:47:46 stsp Exp $ */
|
/* $OpenBSD: lex.c,v 1.47 2013/03/03 19:11:34 guenther Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.185 2013/05/02 21:59:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.186 2013/06/01 00:15:57 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* states while lexing word
|
* states while lexing word
|
||||||
@ -338,7 +338,9 @@ yylex(int cf)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\'':
|
case '\'':
|
||||||
open_ssquote:
|
open_ssquote_unless_heredoc:
|
||||||
|
if ((cf & HEREDOC))
|
||||||
|
goto store_char;
|
||||||
*wp++ = OQUOTE;
|
*wp++ = OQUOTE;
|
||||||
ignore_backslash_newline++;
|
ignore_backslash_newline++;
|
||||||
PUSH_STATE(SSQUOTE);
|
PUSH_STATE(SSQUOTE);
|
||||||
@ -501,7 +503,8 @@ yylex(int cf)
|
|||||||
PUSH_STATE(STBRACEKORN);
|
PUSH_STATE(STBRACEKORN);
|
||||||
} else {
|
} else {
|
||||||
ungetsc(c);
|
ungetsc(c);
|
||||||
if (state == SDQUOTE)
|
if (state == SDQUOTE ||
|
||||||
|
state == SQBRACE)
|
||||||
PUSH_STATE(SQBRACE);
|
PUSH_STATE(SQBRACE);
|
||||||
else
|
else
|
||||||
PUSH_STATE(SBRACE);
|
PUSH_STATE(SBRACE);
|
||||||
@ -622,6 +625,8 @@ yylex(int cf)
|
|||||||
case SSQUOTE:
|
case SSQUOTE:
|
||||||
if (c == '\'') {
|
if (c == '\'') {
|
||||||
POP_STATE();
|
POP_STATE();
|
||||||
|
if ((cf & HEREDOC) || state == SQBRACE)
|
||||||
|
goto store_char;
|
||||||
*wp++ = CQUOTE;
|
*wp++ = CQUOTE;
|
||||||
ignore_backslash_newline--;
|
ignore_backslash_newline--;
|
||||||
} else {
|
} else {
|
||||||
@ -699,7 +704,7 @@ yylex(int cf)
|
|||||||
|
|
||||||
case SBRACE:
|
case SBRACE:
|
||||||
if (c == '\'')
|
if (c == '\'')
|
||||||
goto open_ssquote;
|
goto open_ssquote_unless_heredoc;
|
||||||
else if (c == '\\')
|
else if (c == '\\')
|
||||||
goto getsc_qchar;
|
goto getsc_qchar;
|
||||||
common_SQBRACE:
|
common_SQBRACE:
|
||||||
@ -818,7 +823,7 @@ yylex(int cf)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\'':
|
case '\'':
|
||||||
goto open_ssquote;
|
goto open_ssquote_unless_heredoc;
|
||||||
case '$':
|
case '$':
|
||||||
if ((c2 = getsc()) == '\'') {
|
if ((c2 = getsc()) == '\'') {
|
||||||
open_sequote:
|
open_sequote:
|
||||||
|
4
sh.h
4
sh.h
@ -3,7 +3,7 @@
|
|||||||
/* $OpenBSD: table.h,v 1.8 2012/02/19 07:52:30 otto Exp $ */
|
/* $OpenBSD: table.h,v 1.8 2012/02/19 07:52:30 otto Exp $ */
|
||||||
/* $OpenBSD: tree.h,v 1.10 2005/03/28 21:28:22 deraadt Exp $ */
|
/* $OpenBSD: tree.h,v 1.10 2005/03/28 21:28:22 deraadt Exp $ */
|
||||||
/* $OpenBSD: expand.h,v 1.6 2005/03/30 17:16:37 deraadt Exp $ */
|
/* $OpenBSD: expand.h,v 1.6 2005/03/30 17:16:37 deraadt Exp $ */
|
||||||
/* $OpenBSD: lex.h,v 1.12 2013/01/20 14:47:46 stsp Exp $ */
|
/* $OpenBSD: lex.h,v 1.13 2013/03/03 19:11:34 guenther Exp $ */
|
||||||
/* $OpenBSD: proto.h,v 1.34 2012/06/27 07:17:19 otto Exp $ */
|
/* $OpenBSD: proto.h,v 1.34 2012/06/27 07:17:19 otto Exp $ */
|
||||||
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
||||||
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
||||||
@ -164,7 +164,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.656 2013/05/31 23:27:14 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.657 2013/06/01 00:15:58 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R46 2013/05/31"
|
#define MKSH_VERSION "R46 2013/05/31"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user