Re: Following symlinks in globstar (part 2)

2018-04-11 Thread Eric Cook
On 04/11/2018 10:57 AM, Chet Ramey wrote:
> Yep, that's an incompatibility. The `c.c' thing in the original report is
> just a red herring, though.
> 
> Chet
> 

If you are aiming for compatibility with zsh, the fact that `echo **' recurses 
is also a bug.



Re: Following symlinks in globstar (part 2)

2018-04-11 Thread Chet Ramey
On 4/11/18 11:51 AM, Murukesh Mohanan wrote:
> Yep, sorry about that, c.c is selected:
> 
> $ bash -c '(shopt -s globstar; d=$(mktemp -d); cd "$d"; mkdir a; ln -s a b;
> touch a/a.c c.c; echo **/*.c; cd ..; rm -r "$d")'
> a/a.c b/a.c c.c
> 
> Is there a chance of having ** not select symlinks to directories, so that
> b/c.c doesn't show up in the output?

Yes, I'm looking at that.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: Following symlinks in globstar (part 2)

2018-04-11 Thread Murukesh Mohanan
Yep, sorry about that, c.c is selected:

$ bash -c '(shopt -s globstar; d=$(mktemp -d); cd "$d"; mkdir a; ln -s a b;
touch a/a.c c.c; echo **/*.c; cd ..; rm -r "$d")'
a/a.c b/a.c c.c

Is there a chance of having ** not select symlinks to directories, so that
b/c.c doesn't show up in the output?

On Wed, Apr 11, 2018, 23:57 Chet Ramey  wrote:

> On 4/11/18 10:32 AM, Greg Wooledge wrote:
> > On Wed, Apr 11, 2018 at 10:21:03AM -0400, Chet Ramey wrote:
> >> On 4/11/18 12:21 AM, Murukesh Mohanan wrote:
> >>> This has come up in the past, and was somewhat resolved (<
> >>> http://lists.gnu.org/archive/html/bug-bash/2014-03/msg00097.html>),
> but
> >>> bash's behaviour is still a but surprising IMHO. While globstar doesn't
> >>> descend further into symlinks, symlinked directories are selected as a
> >>> candidate for matches to ** itself. But zsh doesn't do this:
> >>
> >> Before I look at this, note that this doesn't demonstrate anything: you
> >> haven't enabled the `globstar' option, so `**' isn't treated specially.
> >>
> >>> $ bash -c '(d=$(mktemp -d); cd "$d"; mkdir a; ln -s a b; touch a/a.c
> c.c;
> >>> echo **/*.c; cd ..; rm -r "$d")'
> >>> a/a.c b/a.c
> >
> > Here's a possibly more useful demonstration:
> >
> > wooledg:~$ mkdir /tmp/x; cd /tmp/x
> > wooledg:/tmp/x$ mkdir dir; ln -s dir link; touch dir/file
> > wooledg:/tmp/x$ shopt -s globstar
> > wooledg:/tmp/x$ echo **
> > dir dir/file link
> > wooledg:/tmp/x$ echo **/file
> > dir/file link/file
> >
> > I think the complaint is about the handling of "**/file" here.
>
> Yep, that's an incompatibility. The `c.c' thing in the original report is
> just a red herring, though.
>
> Chet
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
>
-- 

Muru


Re: Following symlinks in globstar (part 2)

2018-04-11 Thread Greg Wooledge
On Wed, Apr 11, 2018 at 06:16:19PM +0300, Ilkka Virta wrote:
> So, given
> 
> .
> |-- dir
> |   +-- link -> ../otherdir
> +-- otherdir
> +-- subdir
> +-- foo
> 
> (that is: mkdir -p dir otherdir/subdir; ln -s ../otherdir dir/link; touch
> otherdir/subdir/foo )
> 
> dir/**/foo  does not match anything, but  dir/**/subdir  matches
> dir/link/subdir , i.e.  **  looks through the link, but doesn't recurse
> through it? Did I get that right?
> 
> That does seem somewhat surprising. The documentation on globstar doesn't
> seem to mention anything about behaviour re. symlinks either.

What I'm seeing is that **/file in my example, or dir/**/subdir in
your example, acts as if a single * glob had been used.  I.e.
you get (dir/link/subdir) because dir/*/subdir would have matched that,
and I get (dir/file link/file) because */file would have matched that.

With just those two examples, it looks like ** tries to match like
a regular * first, and then only tries recursion if that fails.



Re: Following symlinks in globstar (part 2)

2018-04-11 Thread Ilkka Virta

On 11.4. 17:57, Chet Ramey wrote:

On 4/11/18 10:32 AM, Greg Wooledge wrote:

On Wed, Apr 11, 2018 at 10:21:03AM -0400, Chet Ramey wrote:

On 4/11/18 12:21 AM, Murukesh Mohanan wrote:

This has come up in the past, and was somewhat resolved (<
http://lists.gnu.org/archive/html/bug-bash/2014-03/msg00097.html>), but
bash's behaviour is still a but surprising IMHO. While globstar doesn't
descend further into symlinks, symlinked directories are selected as a
candidate for matches to ** itself. But zsh doesn't do this:



wooledg:/tmp/x$ mkdir dir; ln -s dir link; touch dir/file
wooledg:/tmp/x$ shopt -s globstar
wooledg:/tmp/x$ echo **
dir dir/file link
wooledg:/tmp/x$ echo **/file
dir/file link/file

I think the complaint is about the handling of "**/file" here.


Yep, that's an incompatibility. The `c.c' thing in the original report is
just a red herring, though.


So, given

.
|-- dir
|   +-- link -> ../otherdir
+-- otherdir
+-- subdir
+-- foo

(that is: mkdir -p dir otherdir/subdir; ln -s ../otherdir dir/link; 
touch otherdir/subdir/foo )


dir/**/foo  does not match anything, but  dir/**/subdir  matches 
dir/link/subdir , i.e.  **  looks through the link, but doesn't recurse 
through it? Did I get that right?


That does seem somewhat surprising. The documentation on globstar 
doesn't seem to mention anything about behaviour re. symlinks either.


--
Ilkka Virta / itvi...@iki.fi



Re: Following symlinks in globstar (part 2)

2018-04-11 Thread Chet Ramey
On 4/11/18 10:32 AM, Greg Wooledge wrote:
> On Wed, Apr 11, 2018 at 10:21:03AM -0400, Chet Ramey wrote:
>> On 4/11/18 12:21 AM, Murukesh Mohanan wrote:
>>> This has come up in the past, and was somewhat resolved (<
>>> http://lists.gnu.org/archive/html/bug-bash/2014-03/msg00097.html>), but
>>> bash's behaviour is still a but surprising IMHO. While globstar doesn't
>>> descend further into symlinks, symlinked directories are selected as a
>>> candidate for matches to ** itself. But zsh doesn't do this:
>>
>> Before I look at this, note that this doesn't demonstrate anything: you
>> haven't enabled the `globstar' option, so `**' isn't treated specially.
>>
>>> $ bash -c '(d=$(mktemp -d); cd "$d"; mkdir a; ln -s a b; touch a/a.c c.c;
>>> echo **/*.c; cd ..; rm -r "$d")'
>>> a/a.c b/a.c
> 
> Here's a possibly more useful demonstration:
> 
> wooledg:~$ mkdir /tmp/x; cd /tmp/x
> wooledg:/tmp/x$ mkdir dir; ln -s dir link; touch dir/file
> wooledg:/tmp/x$ shopt -s globstar
> wooledg:/tmp/x$ echo **
> dir dir/file link
> wooledg:/tmp/x$ echo **/file
> dir/file link/file
> 
> I think the complaint is about the handling of "**/file" here.

Yep, that's an incompatibility. The `c.c' thing in the original report is
just a red herring, though.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: Following symlinks in globstar (part 2)

2018-04-11 Thread Greg Wooledge
On Wed, Apr 11, 2018 at 10:21:03AM -0400, Chet Ramey wrote:
> On 4/11/18 12:21 AM, Murukesh Mohanan wrote:
> > This has come up in the past, and was somewhat resolved (<
> > http://lists.gnu.org/archive/html/bug-bash/2014-03/msg00097.html>), but
> > bash's behaviour is still a but surprising IMHO. While globstar doesn't
> > descend further into symlinks, symlinked directories are selected as a
> > candidate for matches to ** itself. But zsh doesn't do this:
> 
> Before I look at this, note that this doesn't demonstrate anything: you
> haven't enabled the `globstar' option, so `**' isn't treated specially.
> 
> > $ bash -c '(d=$(mktemp -d); cd "$d"; mkdir a; ln -s a b; touch a/a.c c.c;
> > echo **/*.c; cd ..; rm -r "$d")'
> > a/a.c b/a.c

Here's a possibly more useful demonstration:

wooledg:~$ mkdir /tmp/x; cd /tmp/x
wooledg:/tmp/x$ mkdir dir; ln -s dir link; touch dir/file
wooledg:/tmp/x$ shopt -s globstar
wooledg:/tmp/x$ echo **
dir dir/file link
wooledg:/tmp/x$ echo **/file
dir/file link/file

I think the complaint is about the handling of "**/file" here.



Re: Following symlinks in globstar (part 2)

2018-04-11 Thread Chet Ramey
On 4/11/18 12:21 AM, Murukesh Mohanan wrote:
> This has come up in the past, and was somewhat resolved (<
> http://lists.gnu.org/archive/html/bug-bash/2014-03/msg00097.html>), but
> bash's behaviour is still a but surprising IMHO. While globstar doesn't
> descend further into symlinks, symlinked directories are selected as a
> candidate for matches to ** itself. But zsh doesn't do this:

Before I look at this, note that this doesn't demonstrate anything: you
haven't enabled the `globstar' option, so `**' isn't treated specially.

> $ bash -c '(d=$(mktemp -d); cd "$d"; mkdir a; ln -s a b; touch a/a.c c.c;
> echo **/*.c; cd ..; rm -r "$d")'
> a/a.c b/a.c

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/