[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dir*/** behavior
From: |
Matt Zyzik |
Subject: |
Re: dir*/** behavior |
Date: |
Mon, 27 Apr 2009 00:34:04 -0400 |
User-agent: |
Mutt/1.5.16 (2007-06-09) |
>> Description:
>> (Note: I am in the root directory of the bash source code)
>>
>> [~/desktop/bash-4.0]$ ls -adl exampl*/**
>> ls: cannot access examples/examples: No such file or directory
>> ls: cannot access examples/examples/complete: No such file or directory
>> ls: cannot access examples/examples/complete/bashcc-1.0.1.tar.gz: No such
>> file
>> or directory
>> ls: cannot access examples/examples/complete/bash_completion: No such file
>> or
>> directory
>> [...]
>>
>> The above-mentioned "ls -adl exampl*/**" command should work the
>> same as "ls
>> -adl examples/**"; however, as shown above, the behavior of the former
>> command is wrong. The
>> commands work properly in both KornShell and Z shell.
>>
>> --Matt Zyzik
>
> I get the same thing. Looks like a bug to me.
>
> - Ian Kelling
I tried to fix this bug myself. I think the below patch is sufficient in
fixing this issue:
--- ../bash-4.0_orig/lib/glob/glob.c 2009-01-04 14:32:30.000000000 -0500
+++ lib/glob/glob.c 2009-04-26 17:22:56.000000000 -0400
@@ -942,7 +942,7 @@
char **array;
register unsigned int l;
- array = glob_dir_to_array (directories[i], temp_results, flags);
+ array = glob_dir_to_array ((dflags & GX_ALLDIRS) ? "" :
directories[i], temp_results, flags);
l = 0;
while (array[l] != NULL)
++l;
That solves the problem and doesn't appear to introduce any other
issues. Please accept this patch, or look at it.
While we're on the globstar topic, I want to mention what looks to be
another bug:
$ ls -adl **
ls: cannot access : No such file or directory
In the above expansion, it appears that an empty string is one of the
expanded elements and gets passed as a parameter to 'ls'.
--Matt Zyzik
thepatch.txt
Description: Text document