Package: bash Version: 3.0-14 Severity: normal
% help if | cat -n 1 if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi 2 The if COMMANDS are executed. If the exit status is zero, then the then 3 COMMANDS are executed. Otherwise, each of the elif COMMANDS are executed 4 in turn, and if the exit status is zero, the corresponding then COMMANDS 5 are executed and the if command completes. Otherwise, the else COMMANDS 6 are executed, if present. The exit status is the exit status of the last 7 command executed, or zero if no condition tested true. The clause in line #7 about "zero if no condition tested true" is confusing, because it's not made sufficiently clear which exit status it means -- one of the COMMANDS or the 'if..fi' as a whole. Also, there's plural trouble: line #1's "if COMMANDS" is singular, (in that particular context), so the verb "are" should be "is"; plural verbs are overused throughout. How I first misread #7: hmmm, "no X is true" implies that "any X is false". But the exit status of a false test is never zero. Example: % if [ 1 = 1 ] ; then echo true:$? ; else echo false:$? ; fi true:0 % if [ 1 = 3 ] ; then echo true:$? ; else echo false:$? ; fi false:1 # "no condition tested true"?? Yet line #7 IS mainly correct, because it's refering to the exit status of 'fi': % if [ x = y ] ; then echo true:$? ; fi ; echo $? 0 Suggested revision with numbers, quoting, a pronoun, and stricter plurals, first draft: if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi The "if COMMANDS" is executed and returns an exit status of 0 or 1. If 0, "then COMMANDS" is executed. If 1, any "elif COMMANDS" are executed in turn; if one of those returns 0, its corresponding "then COMMANDS" is executed and the "if" command completes. Otherwise "else COMMANDS" is executed, if present. The exit status of "fi" is that of the last command executed, or 0 if no condition tested true. Still reads harshly, what with six usages of "executed"; and the singulars are grating -- but accurate. Maybe it'd look better without those numbers, and the last sentence rephrased: The "if COMMANDS" is executed and returns an exit status. If 'true', "then COMMANDS" is executed. If 'false', any "elif COMMANDS" are executed in turn; if one of those returns 'true', its corresponding "then COMMANDS" is executed and the "if" command completes. Otherwise "else COMMANDS" is executed, if present. The exit status of "fi" is 'true' if no condition tested 'true', or else that of the last command executed after a 'then' or an 'else'. Hope this does not induce headaches, (other than my own)... -- System Information: Debian Release: 3.1 APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.9-1-686 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C) Versions of packages bash depends on: ii base-files 3.1.2 Debian base system miscellaneous f ii libc6 2.3.2.ds1-20 GNU C Library: Shared libraries an ii libncurses5 5.4-4 Shared libraries for terminal hand ii passwd 1:4.0.3-30.10 change and administer password and -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]