Article View: gnu.bash.bug
Article #785globbing bug in 1.04
From: Ray Nickson
Date: Wed, 29 Nov 1989 21:40
Date: Wed, 29 Nov 1989 21:40
57 lines
2127 bytes
2127 bytes
This is bash-1.04, gcc-compiled on a sun3 running sunos4, but the bug
should apply on any machine.
bash$ mkdir foo
bash$ cd foo
bash$ touch f1 f2
bash$ echo f* x*
f1 f2 x*
bash$ echo f* x/*
f* x/*
The bug is in the last line; the failure of x/* to glob shouldn't
prevent the successful globbing of f* (it does in csh, which reports
an error, but (our) sh works properly).
The problem is in subst.c, in expand_words_1 (this is abbreviated):
while (tlist)
{
temp_list = shell_glob_filename (tlist->word->word);
/* Handle error cases.
I don't think we should report errors like "No such file
or directory". However, I would like to report errors
like "Read failed". */
if (temp_list == (char **)-1)
{
/* file_error (tlist->word->word); */
return (new_list);
}
orig_list =
make_word_list (copy_word (tlist->word), orig_list);
tlist = tlist->next;
}
[ ... return orig_list ]
This code is entered with both tlist and new_list being the original
command. For some (possibly good) reason, shell_glob_filename returns
(char **)-1 on a `file system error', including ENOENT, but returns a
pointer to (char *)0 (ie. an empty word array) when globbing fails
otherwise.
My (unintelligent and unrecommened) fix was simply to replace
return (new_list);
by
temp_list = malloc(sizeof(char *));
*temp_list = (char *)0;
which memory, in typical cavalier fashion, I never free.
This fixes this problem, it may or may not cause others.
-rgn
--
Ray Nickson, Dept. Comp. Sci., Victoria University of Wellington, New Zealand.
Ray.Nickson@comp.vuw.ac.nz + 64 4 721000x8593
Technical Details
Message-ID:
<8911292146.AA25901@comp.vuw.ac.nz>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!comp.vuw.ac.nz!Ray.NicksonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!comp.vuw.ac.nz!Ray.Nickson From: Ray.Nickson@comp.vuw.ac.nz (Ray Nickson) Newsgroups: gnu.bash.bug Subject: globbing bug in 1.04 Message-ID: <8911292146.AA25901@comp.vuw.ac.nz> Date: 29 Nov 89 21:40:31 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 57