On Wed, Apr 21, 1999 at 06:26:46PM +0200, Stefan `Sec` Zehl wrote:
> On Tue, Apr 20, 1999 at 01:06:20PM -0400, David Shaw wrote:
> > It is safe to do:
> >     mutt-alias-dedupe < your-alias-file > your-alias-file
> 
> If you already use perl, why don't you use perl's faboulus 'in-place
> editing mode'?
> 
> |      -i[extension]
> |           specifies that files processed by the <> construct
> |           are to be edited in-place.  It does this by renaming
> |           the input file, opening the output file by the
> |           original name, and selecting that output file as the
> |           default for print() statements.  The extension, if
> |           supplied, is added to the name of the old file to
> |           make a backup copy.  If no extension is supplied, no
> |           backup is made.
> 
> So just modify '#!/usr/bin/perl' to '#!/usr/bin/perl -i' and call it as
> 
> mutt-alias-dedupe your-alias-file

That won't work due to the structure of the perl script.  If you try it,
you'll end up with a blank alias file.

In-place editing only works when the print statement lives within the
while(<>) loop. Since you can't print out an alias line until you know
that it isn't overridden later in the file, you can't print anything until
you are out of the while loop.  Thus you can't use in-place editing here.

If the script was written to keep the *first* rather than the *last* of a
duplicated alias then it could work.

David

-- 
   David Shaw  |  [EMAIL PROTECTED]  |  WWW http://www.jabberwocky.com/
+---------------------------------------------------------------------------+
   "There are two major products that come out of Berkeley: LSD and UNIX.
      We don't believe this to be a coincidence." - Jeremy S. Anderson

Reply via email to