Various small programs

All these were written because I had a repeated need for a tool that went beyond a one-liner. Although I've tried to make them generic where possible, they may still have some assumptions about the system I was using at the time. Bug reports are still welcome, though.

Currently, everything on this page is written in perl. Read the source (either the comments, or the code itself) for documentation.


This updates a local cygwin mirror. It is similar to what cygwin's own setup.exe does when told to just download files, but it runs from the command-line and so is suitable for running from a cron job.

It can be configured to download binaries and/or source code, and current and/or previous and/or test versions. Each of the 6 resulting combinations is put into its own subdirectory, to make it easier to e.g. copy useful subsets of the data onto a CD.

To actually install the packages, you currently need to use setup.exe. A future version of this tool may be able to do it (though it'll probably require an existing cygwin installation to run under, and so will only be suitable for updating an already-installed system, as opposed to installing from scratch on a new machine).


grep inside C/C++ source, with enough understanding of the syntax to e.g. look only in comments, or only in strings, etc.. Currently has minimal preprocessor support for ignoring #ifdeffed-out sections.


Answer: reverse-order quoting.
-----Question Separator-----
Question: what's the third-most annoying thing about email (after spam and use of html)?

To deal with morons who insist on doing this, this perl-script attempts to rearrange things into a saner order. This version works on the cascade of forwarded mail I wrote it for, but hasn't been tried more generally.

It attempts to read the datestamp out of quoted headers, rather than just assuming reverse-order. This may go wrong if someone's clock is wrong, if different timezones are used, if non-english month-names are used, or if the date is printed in an unrecognised order. (For cases where no date can be parsed, the messages are printed in the reverse of the original order.)

Messages are output indented with nested > characters. Quoted headers are unsplit; other lines are split to fit an 80-column screen. (Quoted headers are assumed to start with "From:" and end with a blank line.)

Only the separator "-----Original Message-----" is currently recognised. Given that outlook is largely responsible for the problem, this will probably catch the vast majority of offenders. There's a list of separators to look for, though, so adding new ones should be easy.


Inserts commas into numbers (at 3-digit intervals), expanding the number into surrounding whitespace where possible. Try piping "ls -l" or "df" through it.


Convert big numbers into smaller quantified numbers. Currently uses powers of 1024; converting to powers of 1000 is left as an exercise.

Chris Hall <>

Valid XHTML 1.0! Valid CSS!