Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!vsi1!wyse!mips!dce From: dce@mips.COM (David Elliott) Newsgroups: comp.unix.questions Subject: Re: test the exit status inside a shell Keywords: exit status Message-ID: <4312@dunkshot.mips.COM> Date: 1 Oct 88 21:28:12 GMT References: <5651@sgistl.SGI.COM> <3741@boulder.Colorado.EDU> <703@necis.UUCP> <826@philmds.UUCP> Reply-To: dce@dunkshot.UUCP (David Elliott) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 32 In article <826@philmds.UUCP> leo@philmds.UUCP (Leo de Wit) writes: >while command1; do commands; done # while command1 succeeds do the commands >until command1; do commands; done # until command1 succeeds do the commands >if command1; do commands; done # if command1 succeeds do the commands ^^ ^^^^ "if" in sh uses "then" and "fi", not "do" and "done", but that's not what I followed up for. An interesting note about while and until is that the actual syntax is while list; do list; done where a "list" is a list of commands (the semicolons can be newlines). This means that the loop a=no while echo "Enter a new value for a: \c" [ "$a" != "no" ] do read a echo "Entered $a" done is a legal loop. I've only seen this used once, but it could be useful as fast machines make it more reasonable to use sh to write interactive commands. -- David Elliott dce@mips.com or {ames,prls,pyramid,decwrl}!mips!dce