On Tue, Jan 06, 2004 at 05:56:37AM -0500, David T-G wrote: > ...and then David Yitzchak Cohen said... > % On Fri, Jan 02, 2004 at 02:41:21PM +0100, Magnus Bäck wrote: > % > Am I missing some subtle point? The -q option seems to be specific to > % > GNU grep, by the way. > % > % Yeah, here's a more portable way to do it: > % if egrep -q '^Subject: .*<eom>$' $file >/dev/null 2>&1 ; then My bad ... that -q should be gone. > If -q is specific to GNU then how is including it "more portable"? Simple: it's not :-) > I'd > think you should skip it entirely, Yup ... as I said, I screwed up :-( > which would also save you from having > to dump stderr since you wouldn't be throwing an error every time you ran > it. Well, yeah, except I'd dump stderr anyway, since there should be no possible error except $file being unreadable (for instance, if it doesn't exist), and that'd be more of a Mutt error than a grep error, so you might as well not have any FD open to the terminal for the grep command, even if you don't expect errors to occur. > I'm not positive (and I don't have a non-GNU system on which to try > it at the moment), but I wouldn't be surprised if the error changed the > exit code of egrep and thus botched the test anyway; it's worth checking. I'm sure it would. The result of an error would be a nonzero exit code, and your editor would be invoked (which is always safe). However, the "correct" (read: what GNU scripts do) way to do it is to toss the -q option altogether. - Dave -- Uncle Cosmo, why do they call this a word processor? It's simple, Skyler. You've seen what food processors do to food, right? Please visit this link: http://rotter.net/israel
Attachment:
pgpWbKzKKYY7U.pgp
Description: PGP signature