From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Chargin Date: Tue, 28 Apr 2015 11:19:07 -0700 Subject: [U-Boot] HUSH logical AND/OR expressions In-Reply-To: References: <1430141961.15069.7.camel@transmode.se> Message-ID: <553FCF1B.4010308@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Joe Hershberger, On 04/28/2015 11:00 AM, Joe Hershberger wrote: > Hi Joakim, > > On Mon, Apr 27, 2015 at 8:39 AM, Joakim Tjernlund > wrote: >> Trying to get a better handle of HUSH shell expressions, this does not work as I expect: >> => false && true || echo ECHO >> => false && false || echo ECHO >> >> none prints ECHO, seems like a bug? > > I think it works as it should. false followed by && will terminate always. > >> This the only one that prints ECHO >>> = true && false || echo ECHO > > This also seems correct. Passing true into && and false into || will > always continue. > I thought hush is supposed to be mostly similar to sh. On my Linux desktop, bash (which is supposed to be backward compatible with sh) says $ which sh /usr/bin/sh $ ls -l /usr/bin/sh lrwxrwxrwx 1 root root 4 Apr 17 14:43 /usr/bin/sh -> bash $ sh --version GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. $ sh sh-4.2$ false && true || echo ECHO ECHO sh-4.2$ false && false || echo ECHO ECHO sh-4.2$ true && false || echo ECHO ECHO sh-4.2$ exit exit Is this one of the places where hush and sh are not the same? Regards, Jim -- Jim Chargin AJA Video Systems jimc at aja.com (530) 271-3334 http://www.aja.com