LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-30-2014, 01:22 AM   #1
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 156

Rep: Reputation: 19
'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 
BASH=/bin/sh
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING='set >/tmp/set.output'
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="25" [3]="1" [4]="release" [5]="x86_64-redhat-linux-gnu")
BASH_VERSION='3.2.25(1)-release'
DIRSTACK=()
EUID=5111
GROUPS=()
HOME=/var/hello
HOSTNAME=hello
HOSTTYPE=x86_64
IFS=' 	
'
LOGNAME=hello
MACHTYPE=x86_64-redhat-linux-gnu
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/bin:/bin
POSIXLY_CORRECT=y
PPID=27700
PS4='+ '
PWD=/var/hello
SHELL=/bin/sh
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=1
TERM=dumb
UID=5111
USER=hello
_=/bin/sh
RHEL6.3:
Code:
$ cat /tmp/set.output 
BASH=/bin/sh
BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_EXECUTION_STRING='set >/tmp/set.output'
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="1" [2]="2" [3]="1" [4]="release" [5]="x86_64-redhat-linux-gnu")
BASH_VERSION='4.1.2(1)-release'
DIRSTACK=()
EUID=5104
GROUPS=()
HOME=/home/hello
HOSTNAME=hello
HOSTTYPE=x86_64
IFS=' 	
'
LOGNAME=hello
MACHTYPE=x86_64-redhat-linux-gnu
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/bin:/bin
POSIXLY_CORRECT=y
PPID=23161
PS4='+ '
PWD=/home/hello
SHELL=/bin/sh
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=1
TERM=dumb
UID=5104
USER=hello
_=/bin/sh
I have changed some output to 'hello' for privacy.

Last edited by Jerry Mcguire; 06-30-2014 at 01:50 AM. Reason: Changed the subject appropriately
 
Old 06-30-2014, 01:42 AM   #2
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 156

Original Poster
Rep: Reputation: 19
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?
 
Old 06-30-2014, 02:47 AM   #3
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 156

Original Poster
Rep: Reputation: 19
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python 2.6 code behaves differently inside function than outside it dracuss Programming 2 03-21-2011 01:51 PM
rsync behaves differently under cron and under my normal environment jjge Linux - Software 1 03-16-2010 09:55 AM
why java panels behaves differently in linux and solaris ?? alred Programming 2 07-20-2006 03:21 AM
applet on linux server behaves differently naijaguy Programming 3 01-07-2005 03:09 PM
shell behaves differently in rl5 and rl3 Warmduvet Linux - General 22 09-22-2004 06:05 PM


All times are GMT -5. The time now is 02:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration