Article View: comp.mail.mh
Article #1994"folder", "inc", "refile" hang or create folder you might not want
From: Jerry Peek
Date: Thu, 01 Mar 1990 14:00
Date: Thu, 01 Mar 1990 14:00
56 lines
3322 bytes
3322 bytes
I do a lot of shell programming with MH. It's mostly *great* for
programming (especially since mh.6 came out)! But one of the "gotchas"
to watch for is the way that "folder" creates folders. Here are some
problems it might cause you in your programs, plus an idea for a change.
>From the folder(1) man page:
"If the specified (or default) folder doesn't exist, the user
will be queried if the folder should be created."
"refile" and "inc" work the same way.
An unattended shell script can do funny things when a user types (oops):
% somescript +inboz &
If the script was started from a shell with job control, any "folder +inboz"
command in the script will hang the script -- while the shell waits for the
user to bring the job into the foreground and answer y/n to "folder" about
creating +inboz. This happens even when stdout and stderr are redirected to
a file, so the user can't see the prompt from "folder"! On shells without job
control, "folder" seems to always create the folder; see the next paragraph.
If "folder" can read *anything* from stdin, like this:
folder +inboz </dev/null
it *will* create a folder *unless* it reads an "n". The "refile" and
"inc" commands do the same thing. (Background jobs on non-job-control
shells always take stdin from /dev/null -- true? If so, the same
thing will *always* happen there.)
Even more, "inc -silent" works like "inc </dev/null"... it always
creates a folder (silently) if needed, and incorporates mail into it.
I'm not excited about this "create unless they answer 'n'" behavior. The
work-around is code like this in shell scripts before every "refile", "inc",
or "folder" (or, at least, before the first use of any folder *name*):
if test -d `mhpath +$folderarg`
then folder +$folderarg >/dev/null 2>&1
else #complain that folder doesn't exist...
fi
I've learned this (the hard way)... but it could burn people who are just
getting started with MH programming.
I think it would be nice to have a new switch like "-nocreate" that tells
"folder", "inc", "refile", etc. to just abort (with a non-zero status) if
the folder doesn't exist. Do I need to R some FM? Are there better fixes?
Can/should this go in MH 6.6.1 -- or at least mention the behavior
in the refile(1), folder(1), and inc(1) man pages?
--Jerry Peek; Syracuse University Academic Computing Services; Syracuse, NY
jdpeek@rodan.acs.syr.edu, JDPEEK@SUNRISE.BITNET +1 315 443-3995
P.S. syntax: folder [+folder] [msg] [switches]
switches are:
-all -[no]fast -[no]header -[no]pack -[no]recurse -[no]total
-[no]print -[no]list -push -pop -(help)
version: MH 6.6 #1[UCI] (ics) of Tue May 24 15:51:53 PDT 1988
options: [BSD42] [BSD43] [BERK] [MHRC] [DUMB] [RPOP] [NETWORK] [BIND]
[RPATHS] [UCI] [MHE] [SENDMTS] [POP]
Technical Details
Message-ID:
<9003011300.AA22789@rodan.acs.syr.edu>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!rodan.acs.syr.EDU!jdpeekShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!rodan.acs.syr.EDU!jdpeek From: jdpeek@rodan.acs.syr.EDU (Jerry Peek) Newsgroups: comp.mail.mh Subject: "folder", "inc", "refile" hang or create folder you might not want Message-ID: <9003011300.AA22789@rodan.acs.syr.edu> Date: 1 Mar 90 14:00:48 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 56