* Mailpath notification message
@ 1996-10-24 4:37 Rusty Hoover
1996-10-24 5:20 ` Jason L Tibbitts III
1996-10-24 7:35 ` Peter Stephenson
0 siblings, 2 replies; 8+ messages in thread
From: Rusty Hoover @ 1996-10-24 4:37 UTC (permalink / raw)
To: zsh-users
Shouldn't this line:
export MAILPATH="~/.mailspool/rusty:~/Mail/z?Zsh mail."
in my .zshenv give me, whenever i return to my
command-line prompt, the message: "Zsh mail." ?
It doesn't. What am i doing wrong? Do i need spaces around the question
mark?
>From the zsh man:
mailpath (MAILPATH) An array (colon-separated list) of filenames to check
for new mail. Each filename can be followed by a ? and a
message that will be printed. The message will undergo
parameter expansion, command substitution and arithmetic
substitution with the variable $_ defined as the name of the
file that has changed. The default message is "You have new
mail." If an element is a directory instead of a file the
shell will recursively check every file in every
subdirectory of the element.
--
Rusty Hoover
rusty@panix.com
mqw@inch.com
rjh@well.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Mailpath notification message
1996-10-24 4:37 Mailpath notification message Rusty Hoover
@ 1996-10-24 5:20 ` Jason L Tibbitts III
1996-11-05 20:13 ` Nate Johnston
1996-10-24 7:35 ` Peter Stephenson
1 sibling, 1 reply; 8+ messages in thread
From: Jason L Tibbitts III @ 1996-10-24 5:20 UTC (permalink / raw)
To: Rusty Hoover; +Cc: zsh-users
>>>>> "RH" == Rusty Hoover <rusty@panix.com> writes:
RH> It doesn't. What am i doing wrong? Do i need spaces around the question
RH> mark?
I struggled with this for a little while, and came up with the following:
mailpath=(
/var/mail/tibbs\?'New unfiltered mail.'
~/Mail/spool\?'New spooled mail: ${${_%.spool}#/home/tibbs/Mail/spool/}.'
)
I have something like fifty mail spools, each looking like
/home/tibbs/spool/zsh.spool. This will report "New unfiltered mail" for
mail in the system spool directory, and will extract the name of the spool
form the other spool directories.
--
Jason L. Tibbitts III - tibbs@uh.edu - 713/743-8684 - 221SR1
System Manager: University of Houston High Performance Computing Center
1994 PC800 "Kuroneko" DoD# 1723
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Mailpath notification message
1996-10-24 4:37 Mailpath notification message Rusty Hoover
1996-10-24 5:20 ` Jason L Tibbitts III
@ 1996-10-24 7:35 ` Peter Stephenson
1996-10-24 8:41 ` Duncan Sargeant
1 sibling, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 1996-10-24 7:35 UTC (permalink / raw)
To: Zsh users list, Rusty Hoover
Rusty Hoover wrote:
> Shouldn't this line:
>
> export MAILPATH="~/.mailspool/rusty:~/Mail/z?Zsh mail."
>
> in my .zshenv give me, whenever i return to my
> command-line prompt, the message: "Zsh mail." ?
>
> It doesn't. What am i doing wrong? Do i need spaces around the question
> mark?
The mistake is that the ~'s are quoted, so don't expand to your home
directory: try `echo ~ "~"' and you will see what I mean. You need
something like:
export MAILPATH=~/.mailspool/rusty:~/Mail/z'?Zsh mail.'
(zsh does know about assignments and colons when expanding ~'s). This
is partly my fault: I had something in the FAQ when the shell was
rationalised to quote tildes in this sort of place, but deleted it
when I thought it was no longer necessary.
--
Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Mailpath notification message
1996-10-24 7:35 ` Peter Stephenson
@ 1996-10-24 8:41 ` Duncan Sargeant
1996-10-24 9:11 ` Peter Stephenson
0 siblings, 1 reply; 8+ messages in thread
From: Duncan Sargeant @ 1996-10-24 8:41 UTC (permalink / raw)
To: Peter Stephenson; +Cc: zsh-users, rusty
Peter Stephenson scribbled:
>
> Rusty Hoover wrote:
> > Shouldn't this line:
> >
> > export MAILPATH="~/.mailspool/rusty:~/Mail/z?Zsh mail."
> >
> > in my .zshenv give me, whenever i return to my
> > command-line prompt, the message: "Zsh mail." ?
> >
> > It doesn't. What am i doing wrong? Do i need spaces around the question
> > mark?
>
> The mistake is that the ~'s are quoted, so don't expand to your home
> directory: try `echo ~ "~"' and you will see what I mean. You need
> something like:
>
> export MAILPATH=~/.mailspool/rusty:~/Mail/z'?Zsh mail.'
>
> (zsh does know about assignments and colons when expanding ~'s). This
> is partly my fault: I had something in the FAQ when the shell was
> rationalised to quote tildes in this sort of place, but deleted it
> when I thought it was no longer necessary.
>
I usually overcome this problem by using $HOME in my scripts. I
think this is a better way because you can put it in the middle of
double-quote quoted strings (but not single quotes.)
export MAILPATH="$HOME/mailspool/rusty:$HOME/Mail/z?Zsh mail."
IMHO its a good habit to get into.
better understand parameter expansion??
echo $HOME "$HOME" '$HOME' ~ "~" '~'
/home/wheel/dunc /home/wheel/dunc $HOME /home/wheel/dunc ~ ~
PS: what was the rationale behind quoting tildes? Not critising
it, but this means it isn't a short parameter ... so what is
it?
cheers,
dunc
--
Duncan Sargeant, http://www.ucc.gu.uwa.edu.au/~dunc/
D2: "Are you thinking what I'm thinking, D1?"
D1: "I think I am, D2!"
D1 and D2: "Free Tibet!" -- "Dalai Lamas in Pyjamas", GNW.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Mailpath notification message
1996-10-24 8:41 ` Duncan Sargeant
@ 1996-10-24 9:11 ` Peter Stephenson
0 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 1996-10-24 9:11 UTC (permalink / raw)
To: Zsh users list
Duncan Sargeant wrote:
> PS: what was the rationale behind quoting tildes? Not critising
> it, but this means it isn't a short parameter ... so what is
> it?
Since it operates on filenames, it's a bit more like globbing than
like parameters, though it's not quite that either --- you can quote ~
just like you can quote *. I think POSIX has some words on the
subject so that the current semantics is unlikely to change.
--
Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Mailpath notification message
1996-10-24 5:20 ` Jason L Tibbitts III
@ 1996-11-05 20:13 ` Nate Johnston
1996-11-05 21:19 ` Bart Schaefer
0 siblings, 1 reply; 8+ messages in thread
From: Nate Johnston @ 1996-11-05 20:13 UTC (permalink / raw)
To: zsh-users
Quite a while ago, there was a person asking how to string long lines into
his MAILPATH. This is (approximately) what was written as an answer,
perhaps by Mr. Stephenson (if I remember truly).
setopt magic_equal_subst # for `export foo=~/bar`
function export() { EXPORT=${1%%\=*} ; typeset -Ux $* }
function +() { eval builtin export ${EXPORT}=\$\{$EXPORT\}:\$1 }
# some stuff snipped
export MAILPATH= "~/mail/in/inbox?Mail in folder 1"
+ "~/.samizdat/in/inbox?Mail in filder 2"
# more snipped
unfunction export +
This used to work for me. Now however, I get the message that the second
one (~/.samizdat..etc) is not an identifier. I am puzzled, as I loved
this little tool to work on my many mail spools. How might this be made
to work?
This is zsh 3.0.0
--N.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Mailpath notification message
1996-11-05 20:13 ` Nate Johnston
@ 1996-11-05 21:19 ` Bart Schaefer
1996-11-06 5:56 ` Dan Nelson
0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 1996-11-05 21:19 UTC (permalink / raw)
To: Nate Johnston, zsh-users
On Nov 5, 3:13pm, Nate Johnston wrote:
} Subject: Re: Mailpath notification message
}
} Quite a while ago, there was a person asking how to string long lines into
} his MAILPATH. This is (approximately) what was written as an answer,
} perhaps by Mr. Stephenson (if I remember truly).
Nope, it was me.
} setopt magic_equal_subst # for `export foo=~/bar`
} function export() { EXPORT=${1%%\=*} ; typeset -Ux $* }
} function +() { eval builtin export ${EXPORT}=\$\{$EXPORT\}:\$1 }
} # some stuff snipped
} export MAILPATH= "~/mail/in/inbox?Mail in folder 1"
} + "~/.samizdat/in/inbox?Mail in filder 2"
} # more snipped
} unfunction export +
}
} This used to work for me. Now however, I get the message that the second
} one (~/.samizdat..etc) is not an identifier.
The first export has to look like a real variable assignment:
export MAILPATH="~/mail/in/inbox?Mail in folder 1"
+ "~/.samizdat/in/inbox?Mail in filder 2"
It was never supposed to work with spaces after the `=' sign; that it ever
did was because of poor parsing in eariler versions of zsh.
Also, putting quotes around the leading `~' protects that from expansion
even with magic_equal_subst set, so the eventual value of the variable is:
~/mail/in/inbox?Mail in folder 1:~/.samizdat/in/inbox?Mail in filder 2
Which I *think* works for $MAILPATH but would not work for $PATH etc. It
would be better to say (note position of the quotes):
export MAILPATH=~/mail/in/inbox"?Mail in folder 1"
+ ~/.samizdat/in/inbox"?Mail in filder 2"
Finally, what's a filder? ;->
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Mailpath notification message
1996-11-05 21:19 ` Bart Schaefer
@ 1996-11-06 5:56 ` Dan Nelson
0 siblings, 0 replies; 8+ messages in thread
From: Dan Nelson @ 1996-11-06 5:56 UTC (permalink / raw)
To: schaefer; +Cc: Nate Johnston, zsh-users
In the last eposode (Nov 5), Bart Schaefer said:
> On Nov 5, 3:13pm, Nate Johnston wrote:
> } setopt magic_equal_subst # for `export foo=~/bar`
> } function export() { EXPORT=${1%%\=*} ; typeset -Ux $* }
> } function +() { eval builtin export ${EXPORT}=\$\{$EXPORT\}:\$1 }
> } # some stuff snipped
> } export MAILPATH= "~/mail/in/inbox?Mail in folder 1"
> } + "~/.samizdat/in/inbox?Mail in filder 2"
> } # more snipped
> } unfunction export +
That looks.. weird :) I would rather keep sh-style syntax myself, plus
a notation easy for novices to use.
Here is a set of functions based around elm's "frm" command. In
addition to "You have new Z-Shell" mail messages generated by the
mailpath variable, the frm command prints an extra line for every
mailbox with messages in it:
You have no mail.
You have 5 messages from the Z-Shell listserv.
I know only enough about zsh's variable substitution to be dangerous,
so my functions might be affected by setopt's I don't know about.
-Dan Nelson
dnelson@emsphone.com
To use, put these two functions in .zshenv ( or /etc/zshenv):
---.zshenv---
# _subfrm: Counts messages in a mailbox. Argument 1 is the path of the
# mailbox. Argument 2 is assumed to be a string of the form "You have
# new #### mail.". The 2nd word from the right is pulled out and
# included in the message count. No message is printed if the mailbox
# size is 0. Messages are counted by grepping for "From " at the
# beginning of a line. MMDF users might want to search for ^A's.
_subfrm()
{
if [[ -s $@[1] ]] ; then
local msg
msg=(${=@[2]})
echo "You have" $(grep -c "^From " $@[1]) "messages from the $msg[4,-2] listserv."
else
fi
}
# frm: Parses the ZSH mailpath to print number of messages in each
# mailbox. Skips the first entry, which is assumed to be the user's
# main mailbox (handled by the real frm command). Each array element
# after that is passed to _subfrm.
frm()
{
local i
command frm
for i in $mailpath[2,-1]
_subfrm ${(s/?/)i}
true
# This is here so that frm() always returns success
# The picky will want to save the result of "command frm" and
# return that.
}
---.zshenv---
And add these to .zprofile or .zlogin:
---.zprofile---
# Addfrm: Appends a mailbox to the zsh mailpath array. Argument 1 is
# the path to the mailbox. Argument 2 is a single word describing the
# list. Don't quote this to put spaces in it, as _subfrm splits on
# spaces to extract the description from $mailpath.
addfrm()
{
if [[ -z $@[2] ]] ; then
mailpath=($mailpath $@[1])
else
mailpath=($mailpath $@[1]"?You have new "$@[2]" mail.")
fi
}
export MAILPATH=/var/mail/$USER
addfrm ~/Mail/zsh Z-Shell
# Add other mailboxes here
unfunction addfrm
#don't need it any more
---.zprofile---
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~1996-11-06 6:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-24 4:37 Mailpath notification message Rusty Hoover
1996-10-24 5:20 ` Jason L Tibbitts III
1996-11-05 20:13 ` Nate Johnston
1996-11-05 21:19 ` Bart Schaefer
1996-11-06 5:56 ` Dan Nelson
1996-10-24 7:35 ` Peter Stephenson
1996-10-24 8:41 ` Duncan Sargeant
1996-10-24 9:11 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).