romine@XAGSUN.EPM.ORNL.GOV (07/11/89)
I don't know if this has been discussed before, but I dislike the flurry of `file not found' messages that are produced when CDPATH is non-null and an attempt is made to change to a nonexistent directory. The fix is to delete the call to file_error at line 920 of builtins.c (bash-1.02). I fixed the same behavior in versions 0.99 and 1.01. Chuck Romine romine@msr.epm.ornl.gov P.S. I have not mentioned machine/OS configurations, since this is not a machine-dependent phenomenon. It's evidently intentional.
bfox@AUREL.CALTECH.EDU (Brian Fox) (07/11/89)
Date: Mon, 10 Jul 89 14:59:59 -0400 From: romine@xagsun.epm.ornl.gov I don't know if this has been discussed before, but I dislike the flurry of `file not found' messages that are produced when CDPATH is non-null and an attempt is made to change to a nonexistent directory. The fix is to delete the call to file_error at line 920 of builtins.c (bash-1.02). I fixed the same behavior in versions 0.99 and 1.01. Chuck Romine romine@msr.epm.ornl.gov P.S. I have not mentioned machine/OS configurations, since this is not a machine-dependent phenomenon. It's evidently intentional. I don't get a "flurry of file not found" messages. I only get one. Please send your environment, and a recipe with a bug report of this type. It would help, for example, to know what the value of CDPATH is, and if you have "cd" aliased or written as a function, or are using the simple builtin. bfox@aurel$ CDPATH=.:/usr/gnu/src:/usr/gnu:/usr/bin:/usr/src/XV11R3 bfox@aurel$ cd goodfkldfk goodfkldfk: No such file or directory bfox@aurel$ CDPATH=/usr/gnu/src:/usr/gnu:/usr/bin:/usr/src/XV11R3:. bfox@aurel$ cd sldflksdf sldflksdf: No such file or directory bfox@aurel$
romine@XAGSUN.EPM.ORNL.GOV (07/11/89)
Brian,
Sorry about the lack of information -- from reading the code, I just
assumed that the behavior I get was intentional. I built bash-1.02 with
exactly one change (prior to commenting out the line I mentioned), and that
was just the MAINTAINER definition. I'm running on a SUN 3/50 with OS 4.0.1.
(Note: I'm using gcc-1.35 with -traditional to compile bash.)
I have the following environment (using bash as my default shell):
xagsun% set
_=/usr/spool/mail/romine
OLDPWD=/usr/kvm
printman={
if [ $# -eq 1 ] ; then
if [ -r $1 ] ; then
cat $1 | rsh seq psditroff -man -
else
filenam=`whereis -m $1` ; filenam=$filenam:$ ; if [ -r $filenam ] ; then
cat $filenam | rsh seq psditroff -man -
else
echo "function printman: file not found"
fi
fi
else
echo "function usage: printman <name>"
fi
}
print={
for v in $*; do if [ -r $v ] ; then
case "$v" in
*.ps)
cat $v | rsh seq lpr -Plw1 ; shift
;;
*.l | *.man | *.[1-8])
cat $v | rsh seq psditroff -man - ; shift
;;
*)
cat $v | rsh seq enscript -G -fCourier-Bold8 ; shift
;;
esac
else
echo "$v: No such file or directory"
fi
; done
}
man={
if [ -r $1 ] ; then
nroff -man $1 | less
else
/usr/ucb/man $*
fi
}
malias={
for v in $*; do grep $v $HOME/.mailrc ; done
}
look={
for v in $*; do /usr/bin/look -df $v /usr/sun1/local/src/ispell/web | awk -f /us
r/sun1/u0/romine/lib/ispell/expand.new.awk ; done
}
EUID=337
UID=337
HISTSIZE=500
HISTFILE=/usr/u0/romine/.bash_history
BASH_VERSION=1.02
PWD=/usr/dict
MAILPATH=/usr/spool/mail/romine
MAILCHECK=60
IFS=
PS2=bash>
BASH=/usr/gnu/bin/bash
CDPATH=.:..:~:/usr:/usr/sun1:/usr/sun2:/usr/sun1/u0:/u0:/u1:/u2:/seq0:/
DISPLAY=unix:0.0
FLOAT_OPTION=f68881
HOME=/usr/u0/romine
LOGNAME=romine
PATH=/usr/u0/romine/bin:/usr/gnu/bin:/usr/ucb:/bin:/usr/bin:/usr/new:/usr/local:
/usr/local/bin:/etc:/usr/etc:/usr/tex/bin:/usr/local/X11.2/bin:.
PS1=\h%
SHELL=/usr/gnu/bin/bash
SHLVL=5
TERM=xterm
USER=romine
auto_resume=1
ignoreeof=1
no_exit_on_failed_exec=1
nolinks=1
TERMCAP=vs|xterm|...(rest deleted for brevity -- see /etc/termcap)
WINDOWID=6291465
(Note: the artificially high value of SHLVL is due to exec-ing new versions,
but the behavior is reproducible in any case).
xagsun% type cd
cd is a shell builtin
xagsun% cd foobar
./foobar: No such file or directory
../foobar: No such file or directory
/usr/u0/romine/foobar: No such file or directory
/usr/foobar: No such file or directory
/usr/sun1/foobar: No such file or directory
/usr/sun2/foobar: No such file or directory
/usr/sun1/u0/foobar: No such file or directory
/u0/foobar: No such file or directory
/u1/foobar: No such file or directory
/u2/foobar: No such file or directory
/seq0/foobar: No such file or directory
/foobar: No such file or directory
foobar: No such file or directory
foobar: No such file or directory
As I mentioned, commenting out the `offending' line of code, as in the following
segment from builtin.c does the trick:
else
{
if (chdir (newdir) < 0)
{
/*
* commented out by romine to prevent a flurry of `file not found'
* messages when changing to a nonexistent directory, with CDPATH
* nonnull
* file_error (newdir);
*/
return (0);
}
else
{
return (1);
}
}
}
Let me know if there is anything
further that I can do to help you. And, by the way, I'm using bash as my
default shell, not because I think its buggy, but because it's very well-
and carefully-crafted. Thanks for the work you put in. It shows.
Chuck Romine
romine@msr.epm.ornl.gov
(P.S. If it helps, with CDPATH unset, I get two copies of the message, i.e.
xagsun% unset CDPATH
xagsun% cd foobar
foobar: No such file or directory
foobar: No such file or directory
xagsun%bfox@AUREL.CALTECH.EDU (Brian Fox) (07/11/89)
Date: Mon, 10 Jul 89 16:44:39 -0400
From: romine@xagsun.epm.ornl.gov
Brian,
Sorry about the lack of information -- from reading the code,
I just assumed that the behavior I get was intentional. I built
bash-1.02 with exactly one change (prior to commenting out the line I
mentioned), and that was just the MAINTAINER definition. I'm running
on a SUN 3/50 with OS 4.0.1. (Note: I'm using gcc-1.35 with
-traditional to compile bash.)
I have the following environment (using bash as my default shell):
nolinks=1
Hey Chuck, thanks for sending me that stuff. Now I can see that when
`nolinks' is set the bug manifests itself. Here is the complete patch,
which also makes a static variable static:
----------------------------------------
File: ~/source/shell/builtins.c-patch
----------------------------------------
*** builtins.c.~6~ Sun Jul 9 08:56:31 1989
--- builtins.c Mon Jul 10 14:23:23 1989
***************
*** 776,781 ****
--- 776,785 ----
flag. */
int follow_symbolic_links = 1;
+ /* In order to keep track of the working directory, we have this static
+ variable hanging around. */
+ static char *the_current_working_directory = (char *)NULL;
+
cd_builtin (list)
WORD_LIST *list;
{
***************
*** 883,889 ****
change_to_directory (newdir)
char *newdir;
{
- extern char *the_current_working_directory;
char *get_working_directory (), *make_absolute ();
char *t;
--- 887,892 ----
***************
*** 920,938 ****
else
{
if (chdir (newdir) < 0)
! {
! file_error (newdir);
! return (0);
! }
else
! {
! return (1);
! }
}
}
-
-
- char *the_current_working_directory = (char *)NULL;
/* Return a consed string which is the current working directory.
FOR_WHOM is the name of the caller for error printing. */
--- 923,933 ----
else
{
if (chdir (newdir) < 0)
! return (0);
else
! return (1);
}
}
/* Return a consed string which is the current working directory.
FOR_WHOM is the name of the caller for error printing. */
----------------------------------------romine@XAGSUN.EPM.ORNL.GOV (07/11/89)
Brian, Glad to be of help. Thanks for the patch. Chuck romine@msr.epm.ornl.gov (Note: still sending to you via bug-bash@prep.ai.mit.edu because replying to bfox@aurel.caltec bounces).