From patchwork Mon Jan 9 00:12:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13092758 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28285C54EBD for ; Mon, 9 Jan 2023 00:12:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234115AbjAIAMi (ORCPT ); Sun, 8 Jan 2023 19:12:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234052AbjAIAMd (ORCPT ); Sun, 8 Jan 2023 19:12:33 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5EE7B1144A for ; Sun, 8 Jan 2023 16:12:23 -0800 (PST) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id D88981126; Mon, 9 Jan 2023 01:12:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202211; t=1673223140; bh=dEvsxRGwxtTaf1tRKPXRt2rH+AYzQH2luGS+/ohQTcU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AnwIeZNw9t6AWWKi7N2MupvRfJry/wqVr0lAg/kYxeB14km8u6RkZTpphoPnFxHKU ike9KvbUjY1RsWqNq8JsZa9ngxB/FKcJyPYn89JACbikWD8pOPQOmrRlj9U3EQqMD4 yNjtgALtOkbyPcIguO+8M+wFmlkZc5qczunTdRpNqFTBTLgjptVjhsihdcP7JLu5bG VPeAym6XN5EeCJFQ+gVQ+27pvrijyflEYTeMhKP/ACr8RMffMoYgUJHSktZDlOFSSm SG5In/QeaMUEKP9l4qmK3heRJTigulYi4PeHY/9QEolvbKbgNwiWS/HOolb1mrfaFL 3O+GGsZYyuMGA== Date: Mon, 9 Jan 2023 01:12:19 +0100 From: =?utf-8?b?0L3QsNCx?= To: Harald van Dijk Cc: Herbert Xu , dash@vger.kernel.org Subject: [PATCH] alias: fix name quoting in printalias Message-ID: <20230109001219.2ylktzb7uckoeti5@tarta.nabijaczleweli.xyz> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20220429 Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org 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 --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 **