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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15875C10F1B for ; Tue, 13 Dec 2022 20:36:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8C8C785299; Tue, 13 Dec 2022 21:36:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=lutz.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 870A984D64; Tue, 13 Dec 2022 20:50:09 +0100 (CET) Received: from impout006.msg.chrl.nc.charter.net (impout006aa.msg.chrl.nc.charter.net [47.43.20.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2222381191 for ; Tue, 13 Dec 2022 20:50:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=lutz.net Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=bob@lutz.net Received: from server.lan ([47.12.85.154]) by cmsmtp with ESMTP id 5BHvpjFyxCbgv5BHvppU0H; Tue, 13 Dec 2022 19:50:04 +0000 Authentication-Results: lutz.net; none X-Authority-Analysis: v=2.4 cv=YI6MdDKx c=1 sm=1 tr=0 ts=6398d76c a=QTj4GjpxEgg9SGptPdgn3w==:117 a=QTj4GjpxEgg9SGptPdgn3w==:17 a=xqWC_Br6kY4A:10 a=sHyYjHe8cH0A:10 a=mDV3o1hIAAAA:8 a=bd5zq5BtUjI2uTinpTwA:9 a=CjuIK1q_8ugA:10 a=XKFGRTc43nQA:10 a=nczzbHYaOjoA:10 a=typhSwN7sgak89baU_AA:9 a=qe5gv2nwnZ5rD-pg:21 a=_W_S_7VecoQA:10 a=QEXdDO2ut3YA:10 a=_FVE-zBwftR9WsbkzFJk:22 Received: by server.lan (Postfix, from userid 116) id 9D249A23D7A; Tue, 13 Dec 2022 13:50:03 -0600 (CST) Received: from server.lan (localhost [IPv6:::1]) by server.lan (Postfix) with ESMTP id 4F9CBA23D79; Tue, 13 Dec 2022 13:50:03 -0600 (CST) MIME-Version: 1.0 Date: Tue, 13 Dec 2022 13:50:03 -0600 From: Bob To: u-boot@lists.denx.de Cc: Bob Lutz Subject: hush parameter expansion ${parameter:+word} is backwards compared to bash Message-ID: X-Sender: bob@lutz.net X-CMAE-Envelope: MS4xfPkY6rLdr+l7qDwNribm5VxRx33+lRoZHdSWUdZf7MERwudc1uw+7tsKxVwLbvWvHAwRuWthhaZRsWhUThz9L30ZC+b5a4D9qZ6wXChcT/Qoj/4S5rB6 LB4iiNXDVy7XBfmNd5atQbAUEciMg8uZWXu4iQCGlpIq0XPcvr7Qz3sb X-Mailman-Approved-At: Tue, 13 Dec 2022 21:36:01 +0100 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.39 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean I notice that the hush parameter expansion ${parameter:+word} is backwards compared to bash. Here is a test case comparing 'u-boot hush' against 'debian bash'. It shows that at lines 4 and 8, the results are backwards: shell command result u-boot hush result debian-bash ------------------------------------- --------------------- --------------------- 1. var='' 2. echo "\${var} = (${var})" ${var} = () ${var} = () 3. echo "\${var:-bbbb} = (${var:-bbbb})" ${var:-bbbb} = (bbbb) ${var:-bbbb} = (bbbb) 4. echo "\${var:+cccc} = (${var:+cccc})" ${var:+cccc} = (cccc) ${var:+cccc} = () 5. var='aaaa' 6. echo "\${var} = (${var})" ${var} = (aaaa) ${var} = (aaaa) 7. echo "\${var:-bbbb} = (${var:-bbbb})" ${var:-bbbb} = (aaaa) ${var:-bbbb} = (aaaa) 8. echo "\${var:+cccc} = (${var:+cccc})" ${var:+cccc} = () ${var:+cccc} = (cccc) The bash manual says at: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html ${parameter:+word} ------------------ If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted. Example: -------- $ var=123 $ echo ${var:+var is set and not null} var is set and not null