diff mbox series

alias: fix name quoting in printalias

Message ID 20230109001219.2ylktzb7uckoeti5@tarta.nabijaczleweli.xyz (mailing list archive)
State Superseded
Delegated to: Herbert Xu
Headers show
Series alias: fix name quoting in printalias | expand

Commit Message

наб Jan. 9, 2023, 12:12 a.m. UTC
single_quote() over-writes the stack string, so just output the name
separately first.

Fixes: commit 4ec545e8dc98a3f461cf56bed03adafa81c64aec ("alias: Quote
 name in printalias")
---
I coulda swore I tested it and that's where I got my commit message from;
I try to always use my history verbatim for the messages,
for this exact reason.
That said, I can reproduce the bug on trunk and my clean original branch,
so dunno how that got there. my b.

On trunk:
  $ src/dash -c 'alias foo=bar "a|b|c"=d; alias'
  'bar'='bar'
  'd'='d'
With patch:
  $ src/dash -c 'alias foo=bar "a|b|c"=d; alias'
  'foo'='bar'
  'a|b|c'='d'

 src/alias.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/alias.c b/src/alias.c
index 1375cdd..3cd589c 100644
--- a/src/alias.c
+++ b/src/alias.c
@@ -197,7 +197,8 @@  freealias(struct alias *ap) {
 
 void
 printalias(const struct alias *ap) {
-	out1fmt("%s=%s\n", single_quote(ap->name), single_quote(ap->val));
+	out1str(single_quote(ap->name));
+	out1fmt("=%s\n", single_quote(ap->name), single_quote(ap->val));
 }
 
 STATIC struct alias **