Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: main return value is helpfull? Date: Mon, 17 Apr 2017 12:19:04 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <7e8ec0c1-c5ac-4657-8c7f-5c26c5bf0c74@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="6ede04a56392f1431524e35eef643cab"; logging-data="28112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KiKJhn6iO+EkDrD/2fLwV" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:wTFw/kMqsQyr+ozAXM4UhdgU1qg= sha1:18YUPsrzTvXtGN7xyQJyQVaNRiM= Xref: csiph.com comp.lang.c:108240 Lew Pitcher writes: [...] > Unix shell scripting languages have a well-defined behaviour wrt evaluating > the return value from a process. > 1) Unless explicitly tested, the return value (no matter what it is) is > ignored. There's an option (`set -e`) to terminate the script if a command fails, but it's not set by default. > 2) When explicitly tested, a return value of zero (0) is treated as an > indication of success. A non-zero value is /not/ an explicit indication > of failure. It depends on how you test it. For example, the shell's "if" statement treats a return value of 0 as success/true, and any non-zero return value as failure/false. (This is for sh-derived shells, including sh, bash, zsh, kshd. It doesn't necessarily apply to csh, tcsh, fish, etc.) > 3) The script may test for a specific return value, and take action > accordingly. Yes. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"