mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Marc Reilly <marc@cpdesign.com.au>
Cc: barebox@lists.infradead.org
Subject: Re: handling script/init errors
Date: Mon, 18 Nov 2013 10:40:01 +0100	[thread overview]
Message-ID: <20131118094001.GY24559@pengutronix.de> (raw)
In-Reply-To: <1416325.2LyG8l6dzG@dev2.cpdesign>

On Wed, Nov 13, 2013 at 05:51:28PM +1100, Marc Reilly wrote:
> Hi,
> 
>  
> > hush used to interpret return values from commands < 0 as 'exit'. This
> > 
> > changed with this commit:
> > | commit 16edced39ecf4c316179b72c01af249f85b36218
> > | Author: Sascha Hauer <s.hauer@pengutronix.de>
> > | Date:   Fri Aug 10 12:40:01 2012 +0200
> > | 
> > |     hush: Make exit a shell builtin
> > |     
> > |     'exit' used to do its job by returning value < 0. This is a sign
> > |     for hush that 'exit' is executed. This has problems:
> > |     
> > |     - Often commands accidently return a negative value. This causes
> > |     
> > |       the shell to exit.
> > |     
> > |     - execute_binfmt returns a negative value when it does not find
> > |     
> > |       a binary to execute. This again causes the shell to exit.
> > |       Returning a negative error value seems to be the right thing
> > |       to do, but catching this in the shell would mean that the exit
> > |       command does not work anymore.
> > |     
> > |     - if called without arguments exit is supposed to return the code
> > |     
> > |       of the last command. As a command exit has no access to this code.
> > |     
> > |     This patch changes exit to be a builtin and also fixes the last return
> > |     code problem. While at it, update the help text.
> > |     
> > |     Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > 
> > Probably the patch above introduced problems of its own fixed in later
> > commits, so if your device is in production you're better off looking
> > at i2c_write. I assume it returns a negative error value under some
> > circumstances. Let it return 1 instead.
> 
> Thanks!
> 
> In commands/i2c.c: I changed all "return -ENODEV;" to "return COMMAND_ERROR" 
> and the scripts keep executing.
> 
> This fixed it for our version, I'll check if its relevant to current version 
> and send in a patch soon.

This shouldn't be needed in current barebox. The commands now can return
negative error values without causing the shell to exit.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2013-11-18  9:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12  6:07 Marc Reilly
2013-11-12  8:28 ` Sascha Hauer
2013-11-12  9:05   ` Marc Reilly
2013-11-12 10:11     ` Sascha Hauer
2013-11-13  6:51       ` Marc Reilly
2013-11-18  9:40         ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131118094001.GY24559@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=marc@cpdesign.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox