this is a bashism but might be from ksh93 IIRC… still dead ugly as hell!

This commit is contained in:
tg 2010-12-19 20:00:56 +00:00
parent ce160a8155
commit b4948e430f
4 changed files with 36 additions and 9 deletions

20
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.396 2010/11/01 17:29:00 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.397 2010/12/19 20:00:53 tg 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: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2010/11/01
@(#)MIRBSD KSH R39 2010/12/19
description:
Check version of shell.
stdin:
@ -5984,6 +5984,22 @@ expected-stdout:
000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
000000C0 53 34 0A - |S4.|
---
name: dollar-doublequoted-strings
description:
Check that a $ preceding "…" is ignored
stdin:
echo $"Localise me!"
cat <<<$"Me too!"
V=X
aol=aol
cat <<-$"aol"
I do not take a $V for a V!
aol
expected-stdout:
Localise me!
Me too!
I do not take a $V for a V!
---
name: dollar-quoted-strings
description:
Check backslash expansion by $'' strings

14
lex.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.121 2010/09/14 21:26:14 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.122 2010/12/19 20:00:54 tg Exp $");
/*
* states while lexing word
@ -485,9 +485,13 @@ yylex(int cf)
PUSH_STATE(SEQUOTE);
statep->ls_sequote.got_NUL = false;
break;
} else if (c == '"' && (state == SBASE)) {
/* XXX which other states are valid? */
goto DEQUOTE;
} else {
*wp++ = CHAR;
*wp++ = '$';
DEQUOTE:
ungetsc(c);
}
break;
@ -834,7 +838,8 @@ yylex(int cf)
PUSH_STATE(SEQUOTE);
statep->ls_sequote.got_NUL = false;
goto sherestring_quoted;
}
} else if (c2 == '"')
goto sherestring_dquoted;
ungetsc(c2);
goto sherestring_regular;
} else if (c == '\'') {
@ -845,6 +850,7 @@ yylex(int cf)
/* invoke quoting mode */
Xstring(ws, wp)[0] = QCHAR;
} else if (c == '"') {
sherestring_dquoted:
state = statep->ls_state = SHEREDQUOTE;
*wp++ = OQUOTE;
/* just don't IFS split; no quoting mode */
@ -876,7 +882,8 @@ yylex(int cf)
PUSH_STATE(SEQUOTE);
statep->ls_sequote.got_NUL = false;
goto sheredelim_quoted;
}
} else if (c2 == '"')
goto sheredelim_dquoted;
ungetsc(c2);
goto sheredelim_regular;
} else if (c == '\'') {
@ -885,6 +892,7 @@ yylex(int cf)
*wp++ = OQUOTE;
ignore_backslash_newline++;
} else if (c == '"') {
sheredelim_dquoted:
state = statep->ls_state = SHEREDQUOTE;
*wp++ = OQUOTE;
} else {

7
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.242 2010/10/08 17:30:05 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.243 2010/12/19 20:00:55 tg Exp $
.\" $OpenBSD: ksh.1,v 1.138 2010/09/20 07:41:17 jmc Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
@ -71,7 +71,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
.Dd $Mdocdate: October 8 2010 $
.Dd $Mdocdate: December 19 2010 $
.\"
.\" Check which macro package we use
.\"
@ -971,6 +971,9 @@ If a single-quoted string is preceded by an unquoted
C style backslash expansion (see below) is applied (even single quote
characters inside can be escaped and do not terminate the string then);
the expanded result is treated as any other single-quoted string.
If a double-quoted string is preceded by an unquoted
.Ql $ ,
the latter is ignored.
.Ss Backslash expansion
In places where backslashes are expanded, certain C and
.At

4
sh.h
View File

@ -154,9 +154,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.419 2010/11/01 17:29:05 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.420 2010/12/19 20:00:56 tg Exp $");
#endif
#define MKSH_VERSION "R39 2010/11/01"
#define MKSH_VERSION "R39 2010/12/19"
#ifndef MKSH_INCLUDES_ONLY