bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which Bash


From: Bob Proulx
Subject: Re: Which Bash
Date: Sun, 24 Feb 2008 11:58:11 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

Charlse Darwin wrote:
> There are indeed two different versions installed. I have installed  
> the 3.2.33(1)-release version via macports. 2.05b.0(1)-release comes  
> with my OS. I guess my question is how do I get
> 
> $ echo $BASH_VERSION
> to return
> 3.2.33(1)-release
> 
> i.e. How do I get the latest to be the login shell?

I am not familiar with the Mac system so apply appropriate warnings
but on traditional Unix machines the system administrator configures
the list of valid login shell by adding the new shell to the
/etc/shells file.  Then users may change the shell themselves by using
the 'chsh' program.  Here would be one relatively safe process answer:

  $ sudo edit /etc/shells
  ...add /opt/local/bin/bash to list...

  $ chsh

Under the hood the /etc/passwd uses the last entry on the line for the
account for the login shell field.  The list of valid login shells is
stored in /etc/shells.  When a process logs in but doesn't actually
launch the login shell (e.g. ftp) then the login shell is checked
against the /etc/shells list and if not listed there the connection is
rejected.  This handles the case where admins replace the shell with
/bin/false or some other non-shell as a way of disabling the account.
The /etc/shells file also enables the 'chsh' program.  The chsh
program is a suid program enabling non-root users to make their own
edits to their account entry.  Experienced administrators usually just
edit the /etc/passwd file (e.g. using 'vipw') and make the changes
directly.

> Which bash is being used by the system; 3.2.33(1)-release or 2.05b.0
> (1)-release?

The system will continue to use the system version of bash.  It won't
know about your local copy installed into /usr/local or /opt/local.
To be clear "The System" is not your login process.  Changing your
login program to be a different login shell should not affect any of
the system processes.  (Don't change the root user shell however.)
Neither will changing your login shell affect scripts using #!/bin/sh
or #!/bin/bash to select their shell.  If your PATH is configured to
find your locally installed software in /usr/local or /opt/local bin
before the system version in /usr/bin and /bin then it is possible to
use '#!/usr/bin/env bash' in scripts to use the newer version of bash
found on path.  This is commonly done for perl, python, and ruby
programs but is less commonly seen in shell scripts because the system
usually has a working shell in /bin/sh but this technique is useful
when a different script shell is desired.  All that it requires is a
working /usr/bin/env program.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]