[git commit] ash: perform tilde expansion in all parameter expansion words

Denys Vlasenko vda.linux at googlemail.com
Mon May 18 07:51:35 UTC 2015


commit: http://git.busybox.net/busybox/commit/?id=eb6b48ba743d510ad9e6f9c3a8b3899d1eb9b5f3
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Previously tilde expansion was not carried out for =?#% expansion words.

Test case:
   a=~root:~root
   echo ${a#~root}
Old result:
   /root:/root
New result:
   :/root

Based on commit dd721f71 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
subevalvar                                          1152    1153      +1

Signed-off-by: Ron Yorston <rmy at pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c                                        |    4 ++--
 .../var-expand-tilde-in-parameter-expansion.right  |    1 +
 .../var-expand-tilde-in-parameter-expansion.tests  |    2 ++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index a81922a..4c43f1f 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6361,8 +6361,8 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
 	//		p, varname, strloc, subtype, startloc, varflags, quotes);
 
 	herefd = -1;
-	argstr(p, (subtype != VSASSIGN && subtype != VSQUESTION) ? EXP_CASE : 0,
-			var_str_list);
+	argstr(p, EXP_TILDE | (subtype != VSASSIGN && subtype != VSQUESTION ?
+			EXP_CASE : 0), var_str_list);
 	STPUTC('\0', expdest);
 	herefd = saveherefd;
 	argbackq = saveargbackq;
diff --git a/shell/ash_test/ash-vars/var-expand-tilde-in-parameter-expansion.right b/shell/ash_test/ash-vars/var-expand-tilde-in-parameter-expansion.right
new file mode 100644
index 0000000..2357750
--- /dev/null
+++ b/shell/ash_test/ash-vars/var-expand-tilde-in-parameter-expansion.right
@@ -0,0 +1 @@
+:/root
diff --git a/shell/ash_test/ash-vars/var-expand-tilde-in-parameter-expansion.tests b/shell/ash_test/ash-vars/var-expand-tilde-in-parameter-expansion.tests
new file mode 100755
index 0000000..6605315
--- /dev/null
+++ b/shell/ash_test/ash-vars/var-expand-tilde-in-parameter-expansion.tests
@@ -0,0 +1,2 @@
+a=~root:~root
+echo ${a#~root}


More information about the busybox-cvs mailing list