Subject: Re: bin/6794: sh(1) . (dot) command reads files in current directory if not found in the PATH
To: None <mason@primenet.com.au>
From: ITOH Yasufumi <yasufu-i@is.aist-nara.ac.jp>
List: netbsd-bugs
Date: 01/14/1999 20:59:41
In article <slrn79ond1.k9j.mason@coral.primenet.com.au>
mason@primenet.com.au writes:
(see http://mail-index.netbsd.org/mlist/netbsd-bugs/1999/01/13/0001.html)
> You've been fibbing about zsh:
> ``source'' : as ``.'' but cwd is preprended to path
Oops. :-)
> POSIX (older draft) says:
...
Thank you very much for information.
I'm convinced this fix is the right thing.
By the way,
> not be executable. If no readable file is found, a noninteractive shell
> shall abort; an interactive shell shall write a diagnostic message to
by my modification, a noninteractive shell won't abort on "not found."
I'll commit a little different change (using the error() function)
to conform the POSIX behavior.
Thanks,
--
ITOH, Yasufumi <yasufu-i@is.aist-nara.ac.jp>, <itohy@netbsd.org>
Revised patch:
diff -uF^[a-zA-Z_][a-z A-Z0-9_]*(.*[^;]$ main.c.orig main.c
--- main.c.orig Mon Jan 11 23:04:51 1999
+++ main.c Thu Jan 14 20:57:23 1999
@@ -315,22 +315,28 @@ readcmdfile(name)
find_dot_file(basename)
char *basename;
{
- static char localname[FILENAME_MAX+1];
char *fullname;
char *path = pathval();
struct stat statb;
/* don't try this for absolute or relative paths */
- if( strchr(basename, '/'))
+ if (strchr(basename, '/'))
return basename;
while ((fullname = padvance(&path, basename)) != NULL) {
- strcpy(localname, fullname);
+ if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode)) {
+ /*
+ * Don't bother freeing here, since it will
+ * be freed in evalcommand() after return.
+ */
+ return fullname;
+ }
stunalloc(fullname);
- if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode))
- return localname;
}
- return basename;
+
+ /* not found in the PATH */
+ error("%s: not found", basename);
+ /* NOTREACHED */
}
int