LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 12:22 AM   #1
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 201

Rep: Reputation: 31
'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 12:50 AM. Reason: Changed the subject appropriately
 
Old 06-30-2014, 12:42 AM   #2
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 201

Original Poster
Rep: Reputation: 31
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, 01:47 AM   #3
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 201

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



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 12:51 PM
rsync behaves differently under cron and under my normal environment jjge Linux - Software 1 03-16-2010 08:55 AM
why java panels behaves differently in linux and solaris ?? alred Programming 2 07-20-2006 02:21 AM
applet on linux server behaves differently naijaguy Programming 3 01-07-2005 02:09 PM
shell behaves differently in rl5 and rl3 Warmduvet Linux - General 22 09-22-2004 05:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:10 PM.

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
Open Source Consulting | Domain Registration