Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: problem/bug: array definition from command (backticks) - solved

On Jun 26, 11:24pm, Jörg Ziefle wrote:
} mailpath=("$($HOME/bin/printmailfolders-zsh.pl)")
} does The Right Thing (TM).

If it does, it does so by accident.  If printmailfolders-zsh.pl is the
same script you sent in a later message, what the above statement does
is set mailpath to an array consisting of a single element that is a
string with embedded double quotes and backslash-n sequences.  Try a

    print -lr "$mailpath[@]"

after the above and you'll see what I mean: you get one long line with
a lot of quote-backslash-n-quote in it.  I can't possibly see how that's
the result you intended, or how it could report the right thing when new
mail arrives.

Change the last two lines of your perl script to:

    @folders = map { m,^.*/([^/]+)$,; "$_?New mail in $1."} @folders;
    print join "\n", @folders;

Then change your assignment to:

    mailpath=( "${(f)$($HOME/bin/printmailfolders-zsh.pl)}" )

Now try `print -lr "$mailpath[@]"', you should get one line per mailbox.

} > mailpath=(${(f)"$(for i in $HOME/{Mail,savenews}/[^.]*(.rNL+0) ; print $i\?New mail in ${i:t})"})
} Unfortunately, this doesn't work for me.

That's because you still have 3.1.6 and the quoting Clint used only works
after 3.1.9 or thereabouts.

However, did you notice this part of the documentation for `mailpath'?

    The message will undergo parameter expansion, command substitution
    and arithmetic expansion with the variable $_ defined as the name
    of the file that has changed. [...] If an element is a directory
    instead of a file the shell will recursively check every file in
    every subdirectory of the element.

In other words, with no perl at all,

    maildirs=( $HOME/{Mail,savenews} )
    mailpath=( $^maildirs'?New mail in $_' )

will probably do almost everything that you want.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Messages sorted by: Reverse Date, Date, Thread, Author