Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#15606 - [bash] Dot command does not work as expected with /bin/sh

Attached to Project: Arch Linux
Opened by Patrick McCarty (pnorcks) - Monday, 20 July 2009, 21:00 GMT
Last edited by Allan McRae (Allan) - Monday, 20 July 2009, 22:55 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To No-one
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
With Bash 4.0-024, I am running into difficulties running a simple shell script with /bin/sh.

Additional info:
bash 4.0.024-1 (x86_64)

Steps to reproduce:
Create test.sh, and execute this simple command sequence:

bash-4.0$ cat test.sh
#!/bin/sh
echo Hello

bash-4.0$ . test.sh
Hello
bash-4.0$ sh
sh-4.0$ . test.sh
sh: .: test.sh: file not found
This task depends upon

Closed by  Allan McRae (Allan)
Monday, 20 July 2009, 22:55 GMT
Reason for closing:  Not a bug
Comment by Gerardo Exequiel Pozzi (djgera) - Monday, 20 July 2009, 21:38 GMT
If add the "." to search path, work. but anyway, seems that this behaviour is contradictory to manual page: "When bash is not in posix mode, the current directory is searched if no file is found in PATH."

Anyway the old bash 3.2 does the same here.


complete text:
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from
filename. If filename does not contain a slash, file names in PATH are used to find the directory containing filename. The file searched
for in PATH need not be executable. When bash is not in posix mode, the current directory is searched if no file is found in PATH. If
the sourcepath option to the shopt builtin command is turned off, the PATH is not searched. If any arguments are supplied, they become
the positional parameters when filename is executed. Otherwise the positional parameters are unchanged. The return status is the status
of the last command exited within the script (0 if no commands are executed), and false if filename is not found or cannot be read.
Comment by Patrick McCarty (pnorcks) - Monday, 20 July 2009, 22:05 GMT
Interesting. So it looks like this isn't a bug after all.

The behavior of the dot command in Bash 4.0 is now POSIX compliant, whereas in Bash 3.2, it was not.

I thought this was a regression from Bash 3.2, but I guess not. Thanks for the tip.

Loading...