Re: bash 'let' can give error

2010-12-10 Thread Chet Ramey
On 12/10/10 12:17 PM, Marc Herbert wrote: > Le 10/12/2010 16:05, Andreas Schwab a écrit : >>> >>> This is a design mistake: it trades a few characters for a lot of confusion. >> >> You can always choose to ignore the exit status. The converse is not >> true. > > Agreed, but that does not imply an

errexit/set -e again (was: bash 'let' can give error)

2010-12-10 Thread Marc Herbert
Le 10/12/2010 16:19, Dominic Raferd a écrit : > Thanks Greg (and also Eric and Andreas). Your FAQ makes it very clear; > that is to say, it makes it clear how darned complicated it is. Seems > best to avoid using 'set -e' altogether, as you say (except perhaps at > an early stage for debugging):

Re: bash 'let' can give error

2010-12-10 Thread Ken Irving
On Thu, Dec 09, 2010 at 05:52:49PM +, Dominic Raferd wrote: > $ val=0; let val++; echo $val,$?; unset val > 1,1 > > see the error code 1. Setting any other start value (except > undefined) for val does not produce this error, the problem occurs > for let val++ and let val-- if the start value

Re: bash 'let' can give error

2010-12-10 Thread Marc Herbert
Le 10/12/2010 16:05, Andreas Schwab a écrit : >> >> This is a design mistake: it trades a few characters for a lot of confusion. > > You can always choose to ignore the exit status. The converse is not > true. Agreed, but that does not imply any command should try to be creative and throw random

Re: bash 'let' can give error

2010-12-10 Thread Dominic Raferd
On 10/12/2010 15:15, Greg Wooledge wrote: On Thu, Dec 09, 2010 at 05:52:49PM +, Dominic Raferd wrote: Why does this happen? Is it 'by design'? It makes arithmetic with bash let very dangerous because it can throw unexpected errors (and break scripts running with set -e). http://mywiki.wool

Re: bash 'let' can give error

2010-12-10 Thread Andreas Schwab
Marc Herbert writes: >> let intentionally returns status 1 if the value was 0; and status > 1 if >> there was an error. Why? So you can do loops such as: >> >> countdown=10 >> while let countdown--; do ... ; done >> >>> Why does this happen? Is it 'by design'? >> >> Yes. The same as for 'ex

Re: bash 'let' can give error

2010-12-10 Thread Eric Blake
On 12/10/2010 08:49 AM, Marc Herbert wrote: >> let intentionally returns status 1 if the value was 0; and status > 1 if >> there was an error. Why? So you can do loops such as: >> >> countdown=10 >> while let countdown--; do ... ; done >> >>> Why does this happen? Is it 'by design'? >> >> Yes. T

Re: bash 'let' can give error

2010-12-10 Thread Marc Herbert
> let intentionally returns status 1 if the value was 0; and status > 1 if > there was an error. Why? So you can do loops such as: > > countdown=10 > while let countdown--; do ... ; done > >> Why does this happen? Is it 'by design'? > > Yes. The same as for 'expr' which is standardized by POS

Re: bash 'let' can give error

2010-12-10 Thread Andreas Schwab
Dominic Raferd writes: > Why does this happen? Is it 'by design'? $ help let [...] Exit Status: If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise.. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 827

Re: bash 'let' can give error

2010-12-10 Thread Greg Wooledge
On Thu, Dec 09, 2010 at 05:52:49PM +, Dominic Raferd wrote: > Why does this happen? Is it 'by design'? It makes arithmetic with bash > let very dangerous because it can throw unexpected errors (and break > scripts running with set -e). http://mywiki.wooledge.org/BashFAQ/105 -- Why doesn't s

Re: bash 'let' can give error

2010-12-10 Thread Eric Blake
On 12/09/2010 10:52 AM, Dominic Raferd wrote: > Description: > > $ val=0; let val++; echo $val,$?; unset val > 1,1 Not a bug. > > see the error code 1. Setting any other start value (except undefined) > for val does not produce this error, the problem occurs for let val++ > and let val-- if the

bash 'let' can give error

2010-12-10 Thread Dominic Raferd
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linu x-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/ share/locale' -DPACKAGE=