LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-13-2016, 04:18 PM   #1
K4rolis
LQ Newbie
 
Registered: Jan 2016
Posts: 23

Rep: Reputation: Disabled
bash invocation question


Hi,

I've noticed an interesting thing that is not clear to me - why most of the variables from /etc/profile propagate all the way to interactive shells (which is what I would expect), but not the PS1? Where does it get overwritten from
Code:
PS1='\u@\h:\w\$ '
to
Code:
PS1='\s-\v\$ '
?

I actually experimented with exporting a TESTVAR that I defined in /etc/profile, which, as do other variables defined there, propagate to interactive shells for a regular user.

Am I being silly or is this inconsistent?

Last edited by K4rolis; 09-14-2016 at 02:45 AM.
 
Old 09-13-2016, 07:19 PM   #2
STDOUBT
Member
 
Registered: May 2010
Location: Stumptown
Distribution: Slackware64
Posts: 583

Rep: Reputation: 242Reputation: 242Reputation: 242
Off the top of my head, /etc/profile will be overridden by whatever variables are contained in a user's (or even root's) ~/.profile
 
Old 09-13-2016, 07:24 PM   #3
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
There's a lot of stuff in /etc/profile.d too.
 
Old 09-13-2016, 08:10 PM   #4
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,597

Rep: Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690
To get the full story, you will want to investigate the BASH documentation, the disto documentation (luckily, slack has GREAT documents), and do a little local investigation on your own machine. A variable can be set in a LOT of places, but the order and hierarchy will determine which value appears when the session opens.


BTW: the behavior is also different for different shells. The specific shell, and to some extent the version, will change the answers.

This is FUN!
 
Old 09-14-2016, 12:01 AM   #5
vonbiber
Member
 
Registered: Apr 2009
Distribution: slackware 14.1 64-bit, slackware 14.2 64-bit, SystemRescueCD
Posts: 533

Rep: Reputation: 129Reputation: 129
Quote:
Originally Posted by STDOUBT View Post
Off the top of my head, /etc/profile will be overridden by whatever variables are contained in a user's (or even root's) ~/.profile
and, if you are on a x-session, in ~/.bashrc
 
Old 09-14-2016, 01:18 AM   #6
K4rolis
LQ Newbie
 
Registered: Jan 2016
Posts: 23

Original Poster
Rep: Reputation: Disabled
So my brute-force approach to work this out has not worked very well: I've grepped everything (i.e. the root recursively) for 'export.*PS1' (which is, I am aware, bash-specific), and the only hits that I had was in /etc/profile and in /etc/rc.d/rc.S (as well as documentation), but the one in rc.S seems to only be used in case of system repairs (and not general case), so I'm tempted to assume that it is irrelevant.

I do not have any local .profile or .bashrc that touch PS1.
 
Old 09-14-2016, 02:26 AM   #7
55020
Senior Member
 
Registered: Sep 2009
Location: Yorks. W.R. 167397
Distribution: Slackware
Posts: 1,307
Blog Entries: 4

Rep: Reputation: Disabled
http://superuser.com/questions/66306...d-variable-ps1
 
5 members found this post helpful.
Old 09-14-2016, 02:45 AM   #8
K4rolis
LQ Newbie
 
Registered: Jan 2016
Posts: 23

Original Poster
Rep: Reputation: Disabled
55020, this completely answers my question and is consistent with what I suspected. Thank you!

Marking as solved.
 
  


Reply

Tags
bash, ps1



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] using vi, i'd like to be able to scroll back beyond invocation to see O/S work needsleep Linux - Newbie 13 08-23-2011 12:58 AM
[SOLVED] bash invocation question, using 'history' builtin. bartonski Programming 9 10-18-2009 09:00 PM
remote invocation and execution...... chowdhurysoumyadeep Linux - Security 2 09-19-2008 02:43 PM
dbca invocation problem malay_biswal Linux - Laptop and Netbook 0 06-17-2007 12:54 AM
defining wm behaviour on app invocation unholy Programming 0 12-24-2004 02:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:56 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