[U-Boot] HUSH logical AND/OR expressions

James Chargin jimccrown at gmail.com
Tue Apr 28 20:19:07 CEST 2015


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
> <joakim.tjernlund at transmode.se> 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 
<http://gnu.org/licenses/gpl.html>

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


More information about the U-Boot mailing list