Re: Default PS1

2021-03-29 Thread L A Walsh

On 2021/03/29 14:39, Greg Wooledge wrote:

On Mon, Mar 29, 2021 at 01:49:41PM -0700, L A Walsh wrote:
  

Or, what do you mean by 'default'?  Is it sufficient
to set it in the system /etc/profile so it is the default
for all users when logging in?



Sadly, that won't work.  There are plenty of *extremely* common paths
from power-on to shell which do not read /etc/profile.
  


   I have both /etc/profile and /etc/bashrc call my configuration
scripts.  Are there common paths that don't call one of those?

  

  





Re: Default PS1

2021-03-29 Thread Greg Wooledge
On Mon, Mar 29, 2021 at 07:25:53PM -0700, L A Walsh wrote:
> On 2021/03/29 14:39, Greg Wooledge wrote:
> > On Mon, Mar 29, 2021 at 01:49:41PM -0700, L A Walsh wrote:
> > > Or, what do you mean by 'default'?  Is it sufficient
> > > to set it in the system /etc/profile so it is the default
> > > for all users when logging in?
> > 
> > Sadly, that won't work.  There are plenty of *extremely* common paths
> > from power-on to shell which do not read /etc/profile.
> 
>I have both /etc/profile and /etc/bashrc call my configuration
> scripts.  Are there common paths that don't call one of those?

A vanilla bash compiled from GNU sources with no modifications will
not source /etc/bash.bashrc or /etc/bashrc or any other such file.
The SYS_BASHRC feature is off by default, and must be enabled at
compile time.  Many Linux distributions enable it, but there are
surely systems with bash installed which have not enabled it.  So
that's one thing.

Any login that uses a graphical Display Manager does not read /etc/profile.
So that's the second thing.

Now imagine a system with a vanilla bash, and a Display Manager login.



Re: Default PS1

2021-03-29 Thread Christopher Dimech
In your .bashrc you can do 

PS1='My-linux-distro $\n'

-
Christopher Dimech
General Administrator - Naiad Informatics - GNU Project (Geocomputation)
- Geophysical Simulation
- Geological Subsurface Mapping
- Disaster Preparedness and Mitigation
- Natural Resource Exploration and Production
- Free Software Advocacy


> Sent: Tuesday, March 30, 2021 at 8:49 AM
> From: "L A Walsh" 
> To: "ილია ჩაჩანიძე" 
> Cc: bug-bash@gnu.org
> Subject: Re: Default PS1
>
> On 2021/03/29 04:04, ილია ჩაჩანიძე wrote:
> > How can I set default PS1 variable from source code?
> >   
> ---
> What do you mean "from source code?" 
> > E.g I want it to display:
> > My-linux-distro $
> > And not:
> > Bash-5.1 $
> >   
> ---
> Does the procedure documented in the bash man page not work?
> 
> Or, what do you mean by 'default'?  Is it sufficient
> to set it in the system /etc/profile so it is the default
> for all users when logging in?
> 
> 
> 
> 
>



Re: Default PS1

2021-03-29 Thread Greg Wooledge
On Mon, Mar 29, 2021 at 01:49:41PM -0700, L A Walsh wrote:
> Or, what do you mean by 'default'?  Is it sufficient
> to set it in the system /etc/profile so it is the default
> for all users when logging in?

Sadly, that won't work.  There are plenty of *extremely* common paths
from power-on to shell which do not read /etc/profile.

This sort of request (a polite word) is precisely why SYS_BASHRC was
created.



Re: Default PS1

2021-03-29 Thread L A Walsh

On 2021/03/29 04:04, ილია ჩაჩანიძე wrote:

How can I set default PS1 variable from source code?
  

---
   What do you mean "from source code?" 

E.g I want it to display:
My-linux-distro $
And not:
Bash-5.1 $
  

---
Does the procedure documented in the bash man page not work?

Or, what do you mean by 'default'?  Is it sufficient
to set it in the system /etc/profile so it is the default
for all users when logging in?






Re: Default PS1

2021-03-29 Thread Greg Wooledge
On Mon, Mar 29, 2021 at 01:42:10PM +0100, Chris Elvidge wrote:
> On 29/03/2021 12:04 pm, ილია ჩაჩანიძე wrote:
> > How can I set default PS1 variable from source code?
> > E.g I want it to display:
> > My-linux-distro $
> > And not:
> > Bash-5.1 $
> > 
> 
> Set it in $HOME/.bashrc

Given that the goal is clearly to make a new "default" for all users
on their custom operating system, a more viable answer is probably
to enable the SYS_BASHRC feature in config-top.h and then set the PS1
variable in /etc/bash.bashrc (or whatever file they point it to) to
advertise their operating system to people who already run it.



Re: Default PS1

2021-03-29 Thread Chris Elvidge

On 29/03/2021 12:04 pm, ილია ჩაჩანიძე wrote:

How can I set default PS1 variable from source code?
E.g I want it to display:
My-linux-distro $
And not:
Bash-5.1 $



Set it in $HOME/.bashrc

--
Chris Elvidge
England




Default PS1

2021-03-29 Thread ილია ჩაჩანიძე
How can I set default PS1 variable from source code?
E.g I want it to display:
My-linux-distro $
And not:
Bash-5.1 $


default PS1 is not POSIX-compliant?

2017-03-03 Thread Eric Blake
Chet, can you weigh in on http://austingroupbugs.net/view.php?id=1038 ?
There is a question of whether bash's choice of setting PS1='\s-\v\$ '
is correct in --posix mode, or whether it should be merely PS1='\$ '
when started in sh mode.  Allowing more than just the dollar (or hash
for root) and space would require a tweak to the POSIX wording.

Personally, I _like_ the longer prompt (it quickly lets me know whether
I'm using bash or some other shell), and you can always set PS1 to
whatever you want if the shell-startup default wasn't appropriate, but
if it is easier to patch 'bash --posix' to use a shorter prompt than it
is to fix the POSIX wording, then that may be the course to take.

Also, the bash behavior of modifying PS4 during subshells does not match
what other shells do.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature