Skip to contentSkip to conversation

Do not split the result of tilde expansion

PATCH In review Jilles Tjoelker 2 participants 2 messages Dec 5, 2010 – Mar 10, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not split the result of tilde expansion

A tilde expansion generates a valid pathname. Splitting it using IFS either leaves it unchanged or changes it to something unintended.

This fixes FreeBSD sh test expansion/tilde1.0 and does not change the outcome of the other tests.

This fixes Debian bug #601096.

Example:
IFS=m HOME=/tmp; printf "%s\n" ~

---
 src/expand.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
src/expand.c +0 -1
index 1b77b7c..60d4798 100644
@@ -395,7 +395,6 @@ done:
 	*p = c;
 	startloc = expdest - (char *)stackblock();
 	strtodest(home, SQSYNTAX, quotes);
-	recordregion(startloc, expdest - (char *)stackblock(), 0);
 	return (p);
 lose:
 	*p = c;
Signature · 1 line
1.7.3.2
#1 lore raw
Quoted 10 lines · Jilles Tjoelker

A tilde expansion generates a valid pathname. Splitting it using IFS either leaves it unchanged or changes it to something unintended.

This fixes FreeBSD sh test expansion/tilde1.0 and does not change the outcome of the other tests.

This fixes Debian bug #601096.

Example:
IFS=m HOME=/tmp; printf "%s\n" ~

Thanks for the patch! I also removed startloc which is now unused.

commit 834629283f6c629a4da05ef60bae9445c954a19a

Author: Jilles Tjoelker <[email protected]>
Date:   Thu Mar 10 17:16:13 2011 +0800

[EXPAND] Do not split the result of tilde expansion

A tilde expansion generates a valid pathname. Splitting it using IFS either leaves it unchanged or changes it to something unintended.

This fixes FreeBSD sh test expansion/tilde1.0 and does not change the outcome of the other tests.

This fixes Debian bug #601096.

Example:
IFS=m HOME=/tmp; printf "%s\n" ~

ChangeLog +1 -0
index c94dff8..a64e030 100644
@@ -1,6 +1,7 @@
 2011-03-10  Jilles Tjoelker <[email protected]>
 
 	* Replace GPL noclobberopen code with the FreeBSD version.
+	* Do not split the result of tilde expansion.
 
 2010-11-28  Maciej Żenczykowski <[email protected]>
 
src/expand.c +0 -3
index 1b77b7c..6bee5c5 100644
@@ -364,7 +364,6 @@ exptilde(char *startp, char *p, int flag)
 	char *name;
 	const char *home;
 	int quotes = flag & QUOTES_ESC;
-	int startloc;
 
 	name = p + 1;
 
@@ -393,9 +392,7 @@ done:
 	if (!home || !*home)
 		goto lose;
 	*p = c;
-	startloc = expdest - (char *)stackblock();
 	strtodest(home, SQSYNTAX, quotes);
-	recordregion(startloc, expdest - (char *)stackblock(), 0);
 	return (p);
 lose:
 	*p = c;

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt