aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-08-17 03:24:13 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-08-17 03:24:13 +0200
commit7423bbbe98dae5300f49ed45ffd42f44103b2078 (patch)
tree3166dbfa7dcd8f0504a1176f45912a184523db9a /shell
parent5ba6ad7733ca566627afb7c76184d27417b28228 (diff)
downloadbusybox-w32-7423bbbe98dae5300f49ed45ffd42f44103b2078.tar.gz
busybox-w32-7423bbbe98dae5300f49ed45ffd42f44103b2078.tar.bz2
busybox-w32-7423bbbe98dae5300f49ed45ffd42f44103b2078.zip
hush: fix nested alias expansion
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/shell/hush.c b/shell/hush.c
index aa6d3759c..1c1333eb1 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -46,7 +46,6 @@
46 * special variables (done: PWD, PPID, RANDOM) 46 * special variables (done: PWD, PPID, RANDOM)
47 * follow IFS rules more precisely, including update semantics 47 * follow IFS rules more precisely, including update semantics
48 * tilde expansion 48 * tilde expansion
49 * aliases
50 * "command" missing features: 49 * "command" missing features:
51 * command -p CMD: run CMD using default $PATH 50 * command -p CMD: run CMD using default $PATH
52 * (can use this to override standalone shell as well?) 51 * (can use this to override standalone shell as well?)
@@ -102,7 +101,7 @@
102//config: 101//config:
103//config: It will compile and work on no-mmu systems. 102//config: It will compile and work on no-mmu systems.
104//config: 103//config:
105//config: It does not handle select, aliases, tilde expansion, 104//config: It does not handle select, tilde expansion,
106//config: &>file and >&file redirection of stdout+stderr. 105//config: &>file and >&file redirection of stdout+stderr.
107//config: 106//config:
108// This option is visible (has a description) to make it possible to select 107// This option is visible (has a description) to make it possible to select
@@ -2923,10 +2922,16 @@ static ALWAYS_INLINE int i_has_alias_buffer(struct in_str *i)
2923static void i_prepend_to_alias_buffer(struct in_str *i, char *prepend, char ch) 2922static void i_prepend_to_alias_buffer(struct in_str *i, char *prepend, char ch)
2924{ 2923{
2925 if (i->saved_ibuf) { 2924 if (i->saved_ibuf) {
2926 size_t ofs = i->p - i->albuf; 2925 /* Nested alias expansion example:
2926 * alias a='b c'; alias b='echo A:'
2927 * a
2928 * ^^^ runs "echo A: c"
2929 */
2927 char *old = i->albuf; 2930 char *old = i->albuf;
2928 i->albuf = xasprintf("%s%c%s", prepend, ch, old); 2931 //bb_error_msg("before'%s' p'%s'", i->albuf, i->p);
2929 i->p = i->albuf + ofs; 2932 i->albuf = xasprintf("%s%c%s", prepend, ch, i->p);
2933 i->p = i->albuf;
2934 //bb_error_msg("after'%s' p'%s'", i->albuf, i->p);
2930 free(old); 2935 free(old);
2931 return; 2936 return;
2932 } 2937 }