On Wed, 19 Sep 2001 at 15:09:32 -0400, David T-G wrote:
> ...and then David Champion said...
[snip]
> % Guess someone just can't make up their minds. I wonder whether it's
> % Sun or a standards agency. I wish I still had other platforms....
>
> Yeah.
Well, FreeBSD has the following to say under tr(1):
| COMPATIBILITY
| System V has historically implemented character ranges using the
| syntax ``[c-c]'' instead of the ``c-c'' used by historic BSD
| implementations and standardized by POSIX. System V shell
| scripts should work under this implementation as long as the
| range is intended to map in another range, i.e. the command ``tr
| [a-z] [A-Z]'' will work as it will map the ``['' character in
| string1 to the ``['' character in string2. However, if the shell
| script is deleting or squeezing characters as in the command ``tr
| -d [a-z]'', the characters ``['' and ``]'' will be included in
| the deletion or compression list which would not have happened
| under an historic System V implementation.
[ Online version of the manpage can be found here:
http://www.FreeBSD.org/cgi/man.cgi?query=tr&apropos=0&sektion=1&manpath=FreeBSD+4.3-stable&format=html
(hope the URL gets through intact) ]
So, under the POSIX standard at least (and *BSD, in this case), the One
True Way is:
tr A-Za-z N-ZA-Mn-za-m
Does that work under Solaris?
> % Well, the lesson is that tr usage varies wildly among platforms,
> % just like expr, but we already knew that. :)
That's what POSIX tries to remedy. :)
> % So maybe it's best just to have your .mailcap call that rot13 shell
> % script, and adapt the script to cope with unames appropriately. Or
> % use perl.
>
> sh is portable (see other drifted-off-topic thread :-) but with this
> much garbage rolled in I think I will, indeed, go for perl.
Heavens man, have you no concern for efficiency? :-) If the POSIX
version doesn't work under Solaris, i'd rather go for:
tr ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \
NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm
Much more lightweight, and should work practically anywhere, even if
it involves a bit of extra typing.
Also, as for getting mutt to actually use the filter, i'm surprised no
one has pointed at $display_filter yet.
Instead of resorting to hacks involving .mailcap and (horrors :-) editing
the message's content type[1], you can just do something like:
macro pager ( "<enter-command>set display_filter=\n<enter-command>macro pager \\ca
)\n<display-toggle-weed><display-toggle-weed>"
macro pager ) "<enter-command>set display_filter=rot13\n<enter-command>macro pager
\\ca (\n<display-toggle-weed><display-toggle-weed>"
macro pager \ca ) "Toggle ROT13 decoding"
(Pity there's no way to force mutt to re-parse the message... i'm using
a double <display-toggle-weed> to simulate one.)
Just replace `rot13' with your chosen filter command and you're set; no
extra config required, and no risk of munging actual messages.
[1] What happens if the message you're rot'ing is something besides
text/plain, like text/html f'rinstance? The given macro will just
nuke the content-type from orbit, leaving you looking at HTML
source.
--
Piet Delport <[EMAIL PROTECTED]>
Today's subliminal thought is:
PGP signature