My two cents, would be to add a bit to the man page that says something like:
------- For historical reasons, the following format is also supported for arithmetic evaluation: $[expression] Note, however, that this format is non-standard and that $((expression)) is preferred. ------- At least that way there won't be an undocumented feature. Thanks, Elliott Forney On Mon, Apr 9, 2012 at 8:47 PM, Chet Ramey <chet.ra...@case.edu> wrote: > On 4/9/12 9:07 PM, Linda Walsh wrote: >> >> >> Maarten Billemont wrote: >> >>> Any particular reason for not removing old undocumented functionality, >>> or is that mostly the nature of this beast - dragging along and maintaining >>> ancient code for the sake of compatibility? > >> >> So 'yesturday' is "ancient" for you?... that's really means something. > > You have a peculiar view of history (spelling and grammar, too, but we'll > leave that aside). > >> >> In doing a scan over my /usr partition, >> I see MANY examples in bash 4.1 in it's examples of using $[] -- I would >> hardly call 4.1 "ancient". > > True, I never went back and changed the examples. > >> >> >> Other packages that make use of the syntax: >> >> * wondershaper >> * cifs file system >> * alsa (sound) >> * fonts-config (this is a new project within the past few years) >> * QT4 >> * GoogleBrowser (chromium) >> * RPM >> * YP >> * PM Utils >> * RPMrebuild >> * iproute2 (almost all modern internet functions on linux)... >> * dhcp-client >> - (zsh -- not a real example, but might become alternate system shell if bash >> killed $[] support) >> * Opera - ? (has comment "TODO use $(()) instead of $[] whenever >> possible;...) "whenever possible??" >> * samba >> and a HUGE number in >> ** linux-kernel -- all over the place... >> >> At that point, I was getting too many to keep up with ... so I stopped >> searching... >> >> $[] has is -- I would bet, Universally, used MORE than $(())... > > I believe you'd lose, but it's unprovable either way. Consider the fact, > though, that bash and zsh support $[...], ksh93 and dash support only > $((...)), but that all four support $((...)). > >> Chet -- you should get back to the posix folks and tell them posix is to be >> 'descriptive of usage' (their words), not prescriptive. Just because ksh >> did it differently from everyone else's usage doesn't mean they should go >> with that syntax... > > You have got to be kidding. Don't you realize you're talking about > decisions that are nearly 20 years old? That $[...] was a Posix > invention that only ever appeared in P1003.2d9? That the $((...)) > syntax was adopted officially for P1003.2-1992? That's 1992. Twenty > years ago. > > Bash, and later zsh, implemented $[...] because there was no other > syntax at the time, and to gain some operational experience with > arithmetic expansion in the shell. Bash-1.14 (the oldest I have > readily available) lists both forms of arithmetic expansion, but by > the time bash-2.0 was released in 1995, the manual referred only to > the $((...)) form. That's 17 years ago. Hardly "yesterday". > > Now, it's hardly any problem to keep dragging the $[...] syntax along. > It takes only a few dozen bytes of code. I have no plans to remove it. > But let's not kid ourselves: it's revisionist history to think that > $[...] was widespread before Posix so callously stamped it out. > >> Geez. > > Indeed. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/ >