Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16538
| From | Lawrence Velázquez <vq@larryv.me> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Return from function depending on number of parameters |
| Date | 2020-07-04 12:23 -0400 |
| Message-ID | <mailman.951.1593879834.2574.bug-bash@gnu.org> (permalink) |
| References | <b1c19d38-64c0-f1ae-d08a-1ada435a0022@gmail.com> <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me> <0b8f32e5-0644-526e-59a4-1bad5a474262@passchier.net> <ACF6AB75-5321-42EC-805E-D84048F539C9@larryv.me> |
> On Jul 4, 2020, at 8:12 AM, pepa65 <pepa65@passchier.net> wrote: > > On 04/07/2020 04.39, Lawrence Velázquez wrote: >> It might tell you something that $[...] is not even mentioned in >> the man page for bash 3.2.57, which is decidedly not the current >> version. > > About that, is it for sure that $[] is going to be obsoleted/removed in > the future? Only Chet knows for sure, but "obsolete" need not mean "removed". Given how thoroughly it's been memory-holed, $[...] is about as obsolete as it can get. Removing it would break a lot of old scripts, though. > I happened to use it recently Inadvisable. > and thought it was more readable than $(()) and caused less visual > clutter. Any reason $(()) was preferred? Quoting Chet liberally from https://lists.gnu.org/archive/html/bug-bash/2012-04/msg00034.html: > On 4/7/12 4:45 PM, Linda Walsh wrote: > >> In modifying some released code on my distro, I ran into the extensive use >> of $[arith] as a means for returning arithmetic evaluations of the >> expression. >> >> I vaguely remember something like that from years ago, but never see any >> reference to >> it -- yet it works, and old code seems to rely on it -- and >> "$[(1+2)/3]" looks cleaner than "$(((1+2)/3))". So what's up with that? > > It dates from Posix circa 1990 (1003.2d9, of which I've lost my paper > copy). I implemented it after the Berkeley guys, mostly Marc > Teitelbaum, put it into Posix. It ended up getting dropped in favor > of the ksh $((...)) expansion, at which point everyone deprecated the > old $[...]. I removed it from the manual sometime later, but it still > works as it always has. vq
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Return from function depending on number of parameters Lawrence Velázquez <vq@larryv.me> - 2020-07-04 12:23 -0400
csiph-web