Re: Shell script silently exits. Why?
On Tue, 29 Nov 2016, Pavel A wrote: > > Is it possible to test for active option within ash script? > My version of ash does not seem to recognize "test -o" or [ -o errexit ] To test on errexit you'd do something like: case $- in *e*) echo errexit set ;; *) echo errexit not set ;; esac The $- thing: Special Parameters - (Hyphen.) Expands to the current option flags (the single-letter option names concatenated into a string) as specified on invocation, by the set builtin command, or implicitly by the shell. Cheers, -- Cristian ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Shell script silently exits. Why?
Apologies for late response and thanks for everyone who pointed to the behavior of let command with zero result. Is it possible to test for active option within ash script? My version of ash does not seem to recognize "test -o" or [ -o errexit ] Grepping my scripts does not find the -e option set. Anyway I'm replacing all let commands to $(()) based on opinion on StackOverflow that "let" is not posix-blessed. Thanks, Pavel A. > On 17 Nov 2016, at 17:49, Bastian Bittorfwrote: > > * Pavel A [17.11.2016 16:47]: >> We checked that the script does not contain weird unprintable characters and >> other obvious things. Just plain ascii. > > try with 'set -x' ontop of your script and check the last lines when > executing it. > also: does 'sh -n your_file.sh' complains? > > bye, bastian ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Shell script silently exits. Why?
Arnout Vandecappelle wrote: I guess you have a 'set -e' somewhere in your script? let returns the value it computed, so if $foo is different from 0, it will return non-0. This causes the shell to exit. It's POSIX behaviour. Bash "let" returns 1 if there is a sytax error within the expression or the expression is zero, 0 otherwise. So it is basically a "not" operator, the opposite of what you describe. I'm not sure there is a good reason for "let" to return an exit status depending on the value assigned, whether 0 is returned for a zero or a non-zero value assigned. But bash does exit when let returns 1 and "-e" is set, so that might be the reason. Regarding POSIX behaviour, the list of shell built-ins at http://pubs.opengroup.org/onlinepubs/007904875/idx/sbi.html doesn't even mention "let", and "let" can only implemented as a built-in as it must assign a value to a shell variable. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Shell script silently exits. Why?
On 17-11-16 16:43, Pavel A wrote: > Dear experts, > > We have a strange problem with ash script: the shell silently exits while > executing a script. It is likely caused by a "let" command. > Anyone seen similar behavior? How to debug it? > > Busybox version is 1.22.1 (this is what it prints out, not sure about > configuration and build details). > The same script works well on busybox 1.16.0 > Unfortunately this does not reproduce on small example. > > The failing place in the script looks like; > Somefunc() { > local v > echo "this prints" > let "v = $foo & 0x000FFF " I guess you have a 'set -e' somewhere in your script? let returns the value it computed, so if $foo is different from 0, it will return non-0. This causes the shell to exit. It's POSIX behaviour. Regards, Arnout > echo "this does not print" > } > > We checked that the script does not contain weird unprintable characters and > other obvious things. Just plain ascii. > > Best regards, > pavel_a > > > ___ > busybox mailing list > busybox@busybox.net > http://lists.busybox.net/mailman/listinfo/busybox > -- Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect+32-16-286500 Essensium/Mindhttp://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Shell script silently exits. Why?
Dear experts, We have a strange problem with ash script: the shell silently exits while executing a script. It is likely caused by a "let" command. Anyone seen similar behavior? How to debug it? Busybox version is 1.22.1 (this is what it prints out, not sure about configuration and build details). The same script works well on busybox 1.16.0 Unfortunately this does not reproduce on small example. The failing place in the script looks like; Somefunc() { local v echo "this prints" let "v = $foo & 0x000FFF " echo "this does not print" } We checked that the script does not contain weird unprintable characters and other obvious things. Just plain ascii. Best regards, pavel_a ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox