Message ID | 20230105124947.ewohzmmwddcpj4en@tarta.nabijaczleweli.xyz (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Herbert Xu |
Headers | show |
Series | [RESEND] alias: printalias: quote the name, too | expand |
On Thu, Jan 05, 2023 at 01:49:47PM +0100, наб wrote: > This ensures even something like > alias 'a|b|c=d' > is output by alias as > 'a|b|c'='d' > instead of > a|b|c='d' > which is both "suitable for reinput to the shell" per POSIX > and doesn't execute the aliases as code. > --- > src/alias.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Patch applied. Thanks.
On 08/01/2023 12:07, Herbert Xu wrote: > On Thu, Jan 05, 2023 at 01:49:47PM +0100, наб wrote: >> This ensures even something like >> alias 'a|b|c=d' >> is output by alias as >> 'a|b|c'='d' >> instead of >> a|b|c='d' >> which is both "suitable for reinput to the shell" per POSIX >> and doesn't execute the aliases as code. >> --- >> src/alias.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) > > Patch applied. Thanks. Did either of you test this patch before submitting and pushing it? Actually running current dash git, I'm seeing $ src/dash -c 'alias foo=bar; alias foo' 'bar'='bar' single_quote() is written so that it writes to stackblock() without reserving the memory. The second single_quote() call is always going to clobber the first. Cheers, Harald van Dijk
diff --git a/src/alias.c b/src/alias.c index daeacbb..1375cdd 100644 --- a/src/alias.c +++ b/src/alias.c @@ -197,7 +197,7 @@ freealias(struct alias *ap) { void printalias(const struct alias *ap) { - out1fmt("%s=%s\n", ap->name, single_quote(ap->val)); + out1fmt("%s=%s\n", single_quote(ap->name), single_quote(ap->val)); } STATIC struct alias **