44.9 Testing Your SuccessThe shells let you test for success right on the command line. This gives you a very efficient way to write quick and comprehensible shell scripts.
I'm referring to the
cat filea fileb > filec || exit This means "either cat the files or exit ." If you can't cat the files (if cat returns an exit status of 1), you exit ( 38.4 ) . If you can cat the files, you don't exit; you execute the left side or the right side.
I'm stretching normal terminology a bit here, but I think it's
necessary to clarify the purpose of
Similarly,
lpr file && rm file If lpr fails for some reason, you want to leave the file around. Again, I want to stress how to read this: print the file and delete it. (Implicitly: if you don't print it, don't delete it.) - |
|