On Tue, May 21, 2013 at 08:56:13PM +0200, Jacob Carlborg wrote: > On 2013-05-21 20:34, Nick Sabalausky wrote: > > >Ugh, yea, that's right. I love the unix shell, but I'm convinced that > >having the shell expand globs was a colossal mistake. > > I think it's mostly very handy. [...]
I'm a total unix shell geek (my X11 environment is basically a glorified terminal, no window decorations, everything is maximized, no mouse dependence, etc.), but I have to agree that having the shell expand globs was a mistake. The *reasoning* behind it was NOT a mistake: you want a standard syntax for wildcards across the board, that users can rely on, instead of cp taking one syntax, mv another syntax, and ls yet another syntax. (One example of this latter is the sheer number of regex variations on a typical unix installation, many of which are mutually incompatible, or compatible but with subtle variations that nobody can remember. It's an embarrassment!) The *chosen solution*, though, was mistake. The correct solution was to have a globbing function in a standard library that programs would use to expand wildcards. That's what shared libs are for!!! Having the shell expand wildcards always, by default, causes stupid leaning toothpick syndromes when you *don't* want something expanded. Indeed, the eagerness with which the shell interpolates *everything* is a major annoyance. The worst example is writing bash hexadecimal escapes. If you want a literal \x0d, say, you could just write it like that. But if you're using echo, it has to survive another layer of interpolation, so it has to be \\x0d. But lest this simple case mislead you, let me point out that if you write "echo \\00", that will *not* echo a binary zero... because something, somewhere, seems to specially want to interpolate (or interpret) binary zeroes in an unexpected place; the correct way to write it is \\0000. But if this echo has to pass through, say, a shell 'read' command unscathed, yet another layer of interpolation has to be guarded against, and it becomes a monstrous \\\\0000. And when you want a literal backslash, it's yet another set of exceptions to an otherwise simplistic escape sequence. If strings were only interpolated in the final piece of code that needs it to be interpolated -- like inside the program that needs to expand wildcards by calling the shared lib's glob function -- things would be a LOT saner. T -- One Word to write them all, One Access to find them, One Excel to count them all, And thus to Windows bind them. -- Mike Champion
