GNU bash, version 3.00.15(1)-release (i686-redhat-linux-gnu) Is what I am describing a bug, or lack of understanding?
There are three examples here. If executable file is in cwd and path points to cwd and if the same file is referenced bash executes a file that is outside of the cwd! This to me seems quite dangerous, though I realize it could just be my inexperience with bash. BASHBUG0, simple problem recreation BASHBUG1, actual problem encountered BASHBUG2, unexplained situation Distro: CentOS 4.2 Currently doesn't have yum update available BASHBUG0: command referenced is not command executed BUGDESC: when command to be executed is in current path and cwd alternate cmd executed instead. [EMAIL PROTECTED] bin]$ pwd /home/user/bin [EMAIL PROTECTED] bin]$ ls file1 file2 file3 mycmd file4 [EMAIL PROTECTED] bin]$ which mycmd /bin/mycmd [EMAIL PROTECTED] bin]$ mycmd hello me [EMAIL PROTECTED] bin]$ ./mycmd hello me [EMAIL PROTECTED] bin]$ /bin/mycmd hello you [EMAIL PROTECTED] bin]$ cat /bin/mycmd #!/bin/sh echo "hello you" [EMAIL PROTECTED] bin]$ cat ./mycmd #!/bin/sh echo "hello me" [EMAIL PROTECTED] Desktop]$ sh --version GNU bash, version 3.00.15(1)-release (i686-redhat-linux-gnu) Copyright (C) 2004 Free Software Foundation, Inc. BASHBUG1: path command selection BUGDESC: command referenced is not command executed. Reference from man: An attempt is first made to open the file in the current directory, and, if no file is found, then the shell searches the directories in PATH for the script. [EMAIL PROTECTED] sbin]# pwd /usr/local/sbin [EMAIL PROTECTED] sbin]# ls useradd useraddextra userdel userdelextra userextra.fi [EMAIL PROTECTED] sbin]# which userdel /usr/local/sbin/userdel [EMAIL PROTECTED] sbin]# userdel usage: userdel [-r] name [EMAIL PROTECTED] sbin]# ./userdel here Remove local extras (y to confirm)? No. usage: userdel [-r] name [EMAIL PROTECTED] sbin]# userdel usage: userdel [-r] name [EMAIL PROTECTED] sbin]# ./userdel here Remove local extras (y to confirm)? No. usage: userdel [-r] name [EMAIL PROTECTED] sbin]# echo $PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin BASHBUG2: description or implementation of option P BUGDESC: When P is unset the symlink is still followed, though PS not updated. Reference from man: -P If set, the shell does not follow symbolic links when executing commands such as cd that change the current working directory. It uses the physical directory structure instead. By default, bash follows the logi- cal chain of directories when performing commands which change the current directory. [EMAIL PROTECTED] user]# pwd /home/user [EMAIL PROTECTED] user]# ls -l total 88 drwxrwxr-x 3 user users 4096 Jan 2 00:59 bin drwxrwxr-x 2 user users 4096 Jan 1 06:22 dir2 drwxr-xr-x 4 user users 4096 Jan 2 01:05 dir3 -rw-rw-r-- 1 user users 7522 Nov 19 21:08 file1 drwxr-xr-x 2 user users 4096 Jan 1 04:48 dir4 -rw------- 1 user users 46 Nov 17 14:20 file2 drwxrwxr-- 2 user users 4096 Nov 23 19:35 dir5 drwxrwxr-x 9 user users 4096 Jan 1 05:13 dir6 lrwxrwxrwx 1 root root 24 Nov 4 2005 public_html - > /var/www/html_users/user drwxr-xr-x 2 user users 4096 Jan 30 2000 dir7 drwxrwxr-x 3 user users 4096 Dec 31 02:43 dir8 [EMAIL PROTECTED] user]# set -P [EMAIL PROTECTED] user]# cd public_html [EMAIL PROTECTED] user]# pwd /var/www/html_users/user [EMAIL PROTECTED] user]# cd /home/user [EMAIL PROTECTED] user]# set +P [EMAIL PROTECTED] user]# cd public_html [EMAIL PROTECTED] public_html]# pwd /home/user/public_html [EMAIL PROTECTED] public_html]# _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash