bash's globstar considered dumb (** not composable)
William Park
opengeometry-FFYn/CNdgSA at public.gmane.org
Mon Sep 26 04:37:19 UTC 2011
I think '**' came into Bash from Zsh.
--
William
On Sat, Sep 24, 2011 at 04:17:49PM -0400, D. Hugh Redelmeier wrote:
> In the shell, you can write a kind of regular expression to designate
> all files which match that expression. For example, "*.c" designates
> all filenames which end in ".c".
>
> Many years ago, I thought about how the notation ** isn't useful (it
> would just be a synonym for *). and how it could be given another
> interesting meaning. I thought: why not allow it to match files
> within subdirectories too.
>
> I mentioned this to Rob Pike and he responded: bad idea because the
> file structure might not be a tree:
>
> - a DAG (Directed Acyclic Graph) due to hard links for files
>
> - worse due to symlinks (which I still think of as evil)
>
> - there was some thought of allowing hard links to directories (hasn't
> yet happened)
>
> So I dropped the idea.
>
> Fast forward a couple of decades: BASH 4 has this very feature.
> Surely not due to my suggestion.
>
> I tried it for the first time today. I wrote "**.c". It didn't work
> the way I expected. But "**" did. Huh? According to
> <http://wiki.bash-hackers.org/syntax/expansion/globs>
>
> :V4: when the shell option globstar is set, the glob ** will
> recursively match all files and directories. This glob isn't
> "configurable", i.e. you can't do something like **.c to recursively
> get all *.c filenames.
>
> The use of the word "configurable" seems really peculiar to me. For
> one thing, it is configurable: ** only works if you enable the
> "globstar" option. For another, what they clearly mean is composable:
> you cannot compose it with other regular expression operators (which
> includes literal elements).
>
> Not being composable seems really really dumb.
>
> Back to using the awkward but powerful find(1).
> --
> The Toronto Linux Users Group. Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
--
William
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list