ProgrammingThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I don't have a problem but I do have solution that leads to a question.
I created a bash script which sets up paths and variables for some work I do. The header was a basic shebang, #!/bin/bash.
After running my script the environment was exhibiting strange behavior that basically was forcing me to run a command twice. The first invocation would cause an error and the second would work. I have no idea why.
The fix was to add -p to my shebang, #!/bin/bash -p. I tried the -p because I saw it used on some other scripts and not because I understand what it does.
By dumb luck it fixed my issue. commands in the setup work the first time.
I've done some googling trying to figure out what the -p option does but haven't found anything. Nor can I find it in a reference book I have - "Learning the bash shell".
If anyone knows what the -p option does I would love an explanation or a reference to the info.
-p Turned on whenever the real and effective user ids do not match.
Disables processing of the $ENV file and importing of shell
functions. Turning this option off causes the effective uid and
gid to be set to the real uid and gid.
(Edit: clarification this has to do with setuid behavior if you want to research it further)
I don't have a problem but I do have solution that leads to a question.
I've done some googling trying to figure out what the -p option does but haven't found anything. Nor can I find it in a reference book I have - "Learning the bash shell".
Thanks to all.
Well, you forgot the best book that's already on your computer... The man pages. I issued 'man bash' and then entered '/-p' to find
Quote:
If the shell is started with the effective user (group) id not equal to the real user (group) id, and the -p option is not supplied, no startup files are read, shell functions are not inherited from the environment, the SHELLOPTS variable, if it appears in the environment, is ignored, and the effective user id is set to the real user id. If the -p option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset.
Next time, first try 'man' or 'info'. These are the treasure chests of Linux.
Last edited by fruttenboel; 05-21-2010 at 02:53 PM.
Well, you forgot the best book that's already on your computer... The man pages. I issued 'man bash' and then entered '/-p' to find
Next time, first try 'man' or 'info'. These are the treasure chests of Linux.
Our sysadmins, in their infinite wisdom, have setup the man pages to come up in a horrible gui. The gui has nothing but an exit button so there no way to search. Since this gui man has been implemented I almost never use man. The man page for bash is so long it's useless without a search capability. And with the way it's setup I can't pipe it to col -b to create a text file.
Thanks for the help. But now that I know what -p does it's even more confusing how it fixed my problem.
Our sysadmins, in their infinite wisdom, have setup the man pages to come up in a horrible gui. The gui has nothing but an exit button so there no way to search. Since this gui man has been implemented I almost never use man. The man page for bash is so long it's useless without a search capability. And with the way it's setup I can't pipe it to col -b to create a text file.
Thanks for the help. But now that I know what -p does it's even more confusing how it fixed my problem.
Oh well.
Of course therre is a way to search and print it...
Just get the man page on screen and 'paint' the full text with the left mouse button. Then open an editor and paste the text into that buffer (middel mouse button). Repeat until everything is in. Then search (or print, or whatever).
You know, if you read "man less", you'd know that you can actually do very powerful searches. Don't blame the tools for being bad unless you actually know how to use them. Also, if you read "man man", you'd know that you can actually dump any manpage to a printable Postscript document.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.