bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash 'let' can give error


From: Dominic Raferd
Subject: bash 'let' can give error
Date: Thu, 09 Dec 2010 17:52:49 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6

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='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bas
h/include -I../bash/lib   -g -O2 -Wall
uname output: Linux rdiff-backup1 2.6.32-26-generic-pae #48-Ubuntu SMP Wed Nov 2
4 10:31:20 UTC 2010 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 4.1
Patch Level: 5
Release Status: release

Description:

$ 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 is 0.

for let ++val and let --val the problem occurs if the result is 0. Also for the
command:

$ val=10; let val=val+2*2-14; echo $val,$?; unset val


Repeat-By:
See the examples above

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).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]