bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] more ports to Solaris tr, which needs [] around ranges


From: Bruno Haible
Subject: Re: [PATCH] more ports to Solaris tr, which needs [] around ranges
Date: Wed, 6 Oct 2010 01:33:06 +0200
User-agent: KMail/1.9.9

Eric,

> using [] around range expressions is also a valid workaround.  The solution
> still is POSIX-compliant; it's just that you are transliterating [ and ] 
> to themselves in a working tr.

But a workaround like this leads to confusing code. The first time I saw
this use of    tr '[A-Z]' '[a-z]'
in a piece of shell code without comments, about a year or two ago,
I was very confused: Is 'tr' now accepting ranges like 'grep' does?
Does 'tr' use the collation element order? Was the programmer drunk?

> I'd rather use a simple idiom (always use []) than a more complex idiom 
> (play with PATH to find a more-compliant tr) when both are valid 
> workarounds.

Well, I disagree. For me, the gnulib philosophy applied to shell scripts
gives better results. For example, in 'gnulib-tool' we have 168 lines of
code that provide a working 'echo' without dangerous loopholes. Then in the
following 5000 lines of code, the problem is gone, and I can concentrate on
gnulib-tool logic (mostly).

Yes, I know, in case of doubt it is better to consult the Autoconf manual,
but over time I want to arrive at a programming style where I can minimize
these lookups and navigate safely.

Likewise, in an Autoconf generated 'configure' file you set LC_ALL=C at the
beginning, rather than having to think about whether it is necessary at every
command later.

In other words, if a portability problem can be fixed once and for all, then
fix it once and for all.

Bruno



reply via email to

[Prev in Thread] Current Thread [Next in Thread]