Hi James, On Tue, Apr 28, 2015 at 1:19 PM, James Chargin <jimccr...@gmail.com> wrote: > 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.tjernl...@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?
The way hush seems to work is it drops out of the entire command if a case is false. Looking at the code in the hush parser, it seems at face value like it should be skipping the command and then picking up the next command (echo), but it clearly doesn't. if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) || (rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) ) skip_more_in_this_rmode=rmode; I always just assumed this was a limitation of hush, but it's now looking like a bug instead. I haven't debugged into it, but I tend to stay away from hush these days. When I've submitted a bug fix to this area I've been told that we should upgrade wholesale instead, and I've haven't been up for that task so far. http://lists.denx.de/pipermail/u-boot/2012-November/139841.html Perhaps there is an easy, minor bugfix for this that would be palette-able. -Joe _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot