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

Re: clobber, diff, and any other suggestions...



Sweth Chandramouli wrote:
>	the first little block of script is, obviously, to create zero-length 
>files (or zero out existing files), because the current settings on zsh on my 
>machine don't let >> create a file, only append, and don't let > clobber a file, 
>only create.  i could swear that the last zsh install i used had the oppostie 
>behavior for both, and that the option to set it was clobber/noclobber, but 
>doing a search on noclobber in the man page returns nothing, while searching for 
>clobber only returns HIST_ALLOW_CLOBBER.  so first, what is that switch?

It is (NO_)CLOBBER, and it is in the man page.  The default is for
CLOBBER to be on; something in your setup must be turning it off.

>                                                                          is 
>there some one-time only version of > and >> to toggle that behavior

>! and >>!

>	the second block should first make a list of every directory under the 
>one in which the script is run, and then check for lines beginning with 
>'Message-ID', 'Message-Id', or 'References' in all files in those directories, 

	find . -type f -print0 | xargs -0 ./process_files

(if you have GNU tools -- otherwise change "-print0" to "-print" and drop
"-0").  This is much more efficient and scalable than anything you can
do in zsh builtins.  The process_files script should be something like

	#!/usr/local/bin/zsh -f
	for f; do
		sed -n '/^$/q
			/^References:/{
				s/^[^:]*: *//
				s/  *$//
				s/  */ /g
				p
			}' $f
		sed -n '/^$/q
			/^Message-I[dD]:/{
				s/^[^:]*: *//
				s/  *$//
				p
			}' $f >&3
	done 3>> messages | tr ' ' '\012' >> referenced

Or you can do all that in Perl for greater efficiency -- those forks
don't come cheap, you know.  When all that has finished, you'll have
files containing unsorted message-IDs.  Run

	comm -13 <(sort messages) <(sort -u referenced)

to get a list of unique message-IDs of messages that are referenced but
not available.

zsh's clever features aren't really helpful on large scale jobs like this,
but its flexible plumbing does come in handy.

-zefram



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