'source' behaves differently in RHEL 5 and 6
In RHEL5.4, the following entries in the crontab works:
* * * * * set >/tmp/set.output * * * * * . my_env && cat my_env >/tmp/deleteme The file my_env is placed under my home directory with mode 644 owned by me. The file /tmp/set.output and /tmp/deleteme are created as expected. However the same entries and the same setup doesn't work in RHEL6.4. It doesn't create or write to /tmp/deleteme although I have permission to create files and write to them in /tmp. The man page says `source` will look for my_env from the PATH. On non-posix shell, the home directory is searched as well. So RHEL6.4 is correct. I wonder if this is an intended improvement or is it something else that makes the behaviour different? RHEL5.4: Code:
$ cat /tmp/set.output Code:
$ cat /tmp/set.output |
More info:
As you can see, the home directories are at different locations on RHEL 5 and 6. So they are not exactly the same. The home directory on RHEL 5 is /var/hello with mode 755. The home directory on RHEL 6 is /home/hello with mode 700. Yet I don't think they make a different in my case, do they? |
A friend sent me a official explanation with the following link.
https://access.redhat.com/site/docum...nges-Bash.html "Bash-4.0 and later fixes a Posix mode bug that caused the . (source) builtin to search the current directory for its filename argument, even if "." is not in the system PATH. Posix says that the shell should not look in the PWD variable in this case." It is indeed a bug-fix in bash. |
All times are GMT -5. The time now is 04:00 PM. |