From ce43ba61756ee2ed39e760d4f07ccc55471fcce3 Mon Sep 17 00:00:00 2001 From: jilles Date: Fri, 3 Oct 2014 20:24:56 +0000 Subject: [PATCH] sh: Fix LINENO and prompt after $'\0 and newline. --- bin/sh/parser.c | 7 +++++++ bin/sh/tests/builtins/Makefile | 1 + bin/sh/tests/builtins/lineno3.0 | 6 ++++++ bin/sh/tests/builtins/lineno3.0.stdout | 2 ++ 4 files changed, 16 insertions(+) create mode 100644 bin/sh/tests/builtins/lineno3.0 create mode 100644 bin/sh/tests/builtins/lineno3.0.stdout diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 8e98768a79d9..f1f4e0713a88 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1279,6 +1279,13 @@ readcstyleesc(char *out) c = pgetc(); if (c == PEOF) synerror("Unterminated quoted string"); + if (c == '\n') { + plinno++; + if (doprompt) + setprompt(2); + else + setprompt(0); + } } pungetc(); return out; diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile index 07c8098e22b7..d5d96b58a48c 100644 --- a/bin/sh/tests/builtins/Makefile +++ b/bin/sh/tests/builtins/Makefile @@ -100,6 +100,7 @@ FILES+= jobid2.0 FILES+= kill1.0 kill2.0 FILES+= lineno.0 lineno.0.stdout FILES+= lineno2.0 +FILES+= lineno3.0 lineno3.0.stdout FILES+= local1.0 FILES+= local2.0 FILES+= local3.0 diff --git a/bin/sh/tests/builtins/lineno3.0 b/bin/sh/tests/builtins/lineno3.0 new file mode 100644 index 000000000000..eb8f9ab7db94 --- /dev/null +++ b/bin/sh/tests/builtins/lineno3.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +echo before: $LINENO +dummy=$'a\0 +' +echo after: $LINENO diff --git a/bin/sh/tests/builtins/lineno3.0.stdout b/bin/sh/tests/builtins/lineno3.0.stdout new file mode 100644 index 000000000000..6e0e4ac8ca57 --- /dev/null +++ b/bin/sh/tests/builtins/lineno3.0.stdout @@ -0,0 +1,2 @@ +before: 3 +after: 6