Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-31-2012, 09:56 AM
|
#1
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,690
|
bash: set <option> and sub-shells
With the following in mind:
Code:
#!/bin/bash
set +h
./script1.sh
Is set +h also set in script1.sh (and its sub-shells)?
Variables need to be explicitly exported to be recognized in a sub-shell, which makes me wonder if set -/+ X needs to be set in every sub-shell.
Haven't been able to find this info in the bash man page.
Thanks in advance!
|
|
|
|
08-31-2012, 10:04 AM
|
#2
|
|
Member
Registered: May 2010
Location: Planet Earth
Distribution: Debian
Posts: 766
Rep: 
|
|
|
|
|
08-31-2012, 10:15 AM
|
#3
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,690
Original Poster
|
Quote:
Originally Posted by ukiuki
|
That info is also in the man page, but it does not answer my question.
|
|
|
|
08-31-2012, 10:19 AM
|
#4
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,896
|
I'm sure you already did a couple of tests and they revealed that shell options are not inherited from the parent shell. Indeed, this is not clearly mentioned anywhere. Maybe an explanation close to what really happens is given here: http://www.gnu.org/software/bash/man...on-Environment.
Shell options are cited in the list of the execution environment items, but not in the list of items inherited by a subshell. Maybe an indirect and somewhat obscure way to assert the evidence of the facts! 
Last edited by colucix; 08-31-2012 at 10:21 AM.
|
|
|
1 members found this post helpful.
|
08-31-2012, 10:36 AM
|
#5
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,690
Original Poster
|
Quote:
Originally Posted by colucix
I'm sure you already did a couple of tests and they revealed that shell options are not inherited from the parent shell.
|
Yep, I did and I got confused by the results (which is explained by your link). My assumption was that some are and some are not inherited depending on other factors (from the link: set -e is exported when not in POSIX mode).
Assuming that none are inherited is probably the smart thing to do. Better safe then sorry.......
Quote:
Originally Posted by colucix
Indeed, this is not clearly mentioned anywhere. Maybe an explanation close to what really happens is given here: http://www.gnu.org/software/bash/man...on-Environment.
Shell options are cited in the list of the execution environment items, but not in the list of items inherited by a subshell. Maybe an indirect and somewhat obscure way to assert the evidence of the facts! 
|
Thank you!
|
|
|
|
08-31-2012, 11:03 AM
|
#6
|
|
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,036
|
untested#1:
Code:
#!/bin/bash
bash +h ./script1.sh
untested#2:
Code:
#!/bin/bash
set +h
source ./script1.sh
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:00 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|