Skip to contentSkip to conversation

Dash Escape characters problem

DISCUSSION Herbert Xu 1 participant 1 message Jun 27, 2009 1 message not in the archive

lore
Share & tools
lore

Herbert Xu

author
#1 lore raw
In reply to a message not in the archive
Quoted 17 lines · Sven Anders

Hello!

[ Sorry! I'm not sure, if the last messages reached you, so it resent it here... ]

I upgraded from dash 0.5.4 to 0.5.5.1 and have to report a regression.

I want to color some output using escape sequences:

$./dash-0.5.4/src/dash

Quoted 1 line

S="echo -n \\033[0;32mOK\\033[0;39m"; $S

OK

** The "OK" is displayed in green color

Quoted 5 lines

$./dash-0.5.5.1/src/dash

Quoted 1 line

S="echo -n \\033[0;32mOK\\033[0;39m"; $S

033[0;32mOK033[0;39m

** The dash does output the escape sequence itself

Thanks for the report.

I've just fixed it as follows:

commit 0d7d66039b614b642c775432fd64aa8c11f9a64d

Author: Herbert Xu <[email protected]>
Date:   Sat Jun 27 21:00:39 2009 +0800

[EXPAND] Fix quoted pattern patch breakage

The change

[EXPAND] Do not quote back slashes in parameter expansions outside quotes

broke quote removal after parameter expansion. This is because its effecte extended beyond that of quoted patterns.

This patch fixes this by limiting the change to just quoted patterns.

ChangeLog +4 -0
index 2f52f75..e6a1d26 100644
@@ -1,3 +1,7 @@
+2009-06-27  Herbert Xu <[email protected]>
+
+	* Fix quoted pattern patch breakage.
+
 2009-05-23  Herbert Xu <[email protected]>
 
 	* Fix incorrect savefd conversions.
src/expand.c +3 -1
index e4c4c8b..7995d40 100644
@@ -869,7 +869,9 @@ memtodest(const char *p, size_t len, const char *syntax, int quotes) {
 		int c = (signed char)*p++;
 		if (c) {
 			if ((quotes & QUOTES_ESC) &&
-			    (syntax[c] == CCTL || syntax[c] == CDBACK))
+			    ((syntax[c] == CCTL) ||
+			     (((quotes & EXP_FULL) || syntax != BASESYNTAX) &&
+			      syntax[c] == CBACK)))
 				USTPUTC(CTLESC, q);
 		} else if (!(quotes & QUOTES_KEEPNUL))
 			continue;
src/mksyntax.c +2 -3
index 9ecbb45..7a8a9ae 100644
@@ -53,7 +53,6 @@ struct synclass synclass[] = {
 	{ "CWORD",	"character is nothing special" },
 	{ "CNL",	"newline character" },
 	{ "CBACK",	"a backslash character" },
-	{ "CDBACK",	"a backslash character in double quotes" },
 	{ "CSQUOTE",	"single quote" },
 	{ "CDQUOTE",	"double quote" },
 	{ "CENDQUOTE",	"a terminating quote" },
@@ -176,7 +175,7 @@ main(int argc, char **argv)
 	init();
 	fputs("\n/* syntax table used when in double quotes */\n", cfile);
 	add("\n", "CNL");
-	add("\\", "CDBACK");
+	add("\\", "CBACK");
 	add("\"", "CENDQUOTE");
 	add("`", "CBQUOTE");
 	add("$", "CVAR");
@@ -194,7 +193,7 @@ main(int argc, char **argv)
 	init();
 	fputs("\n/* syntax table used when in arithmetic */\n", cfile);
 	add("\n", "CNL");
-	add("\\", "CDBACK");
+	add("\\", "CBACK");
 	add("`", "CBQUOTE");
 	add("$", "CVAR");
 	add("}", "CENDVAR");
src/parser.c +0 -1
index dad1037..28a46c0 100644
@@ -901,7 +901,6 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
 				break;
 			/* backslash */
 			case CBACK:
-			case CDBACK:
 				c = pgetc2();
 				if (c == PEOF) {
 					USTPUTC(CTLESC, out);

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt