Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven.umd.edu!wam.umd.edu!ignatz From: ignatz@wam.umd.edu (Mark J. Sienkiewicz) Newsgroups: comp.os.os9 Subject: Re: SILENT ERROR exits SHell script? Keywords: OSK shell bug Message-ID: <1991Jun5.184640.4481@wam.umd.edu> Date: 5 Jun 91 18:46:40 GMT References: <1991Jun4.230458.25390@cbnewsd.att.com> Sender: usenet@wam.umd.edu (USENET Posting) Organization: University of Maryland at College Park Lines: 47 Nntp-Posting-Host: avw In article <1991Jun4.230458.25390@cbnewsd.att.com> knudsen@cbnewsd.att.com (michael.j.knudsen) writes: >If I run the DIFF utility in a shell script, >it runs fine but immediately exits the script upon completion. >No error message at all -- it just acts as if the script had >reached normal EOF. >I know that non-zero error returns will exit a shell script, >but they always print at least the error number. >How is it that DIFF can break out of the script with no error message? Microware's shell exits whenever a process returns a non-zero exit code. The exit code you are getting is 1 (or 000:001 in microware terms). This error seems to get special treatment by not being printed, but only if you ar executing a script. Is this weird or what? >I don't know where this DIFF came from (Microware, or PD, or what), >but it has another bug that may be related. If you type just >"diff" with no arguments, it responds with > diff: use: diff file1 file2 >ERROR 000:002 Keyboard Abort Here are the standard exit codes for diff: 0 no differences 1 the two files are different 2 some error occured The diff you have is probably either GNU diff or maybe stolen/licensed from Unix. This means you should just ignore the goofy error messages and get on with whatever you are doing. I would also ask "Why do you have diff in a shell script?" Microwares shell doesn't have any way to branch on the result (at least not in the OS9 I have). Normally you would write if diff filea fileb > /dev/null then do-something-because-they-are-the-same else do-something-because-they-are-different fi >I understand this DIFF is buggy and should be replaced with a >better version. But just for my education, how can it *silently* >force the Shell to exit the script? If you have GNU diff, it is in pretty good shape except that it sometimes needs a lot of memory. (of course, OS9 can't swap processes out)