Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Update to a newer bash shell UNIX
Open Terminal, and at the command prompt type bash --version. You're likely to see something like GNU bash, version 2.05b.0(1)-release (powerpc-apple-darwin8.0) -- at least if you're on Tiger, that is. Note that you'll have a powerpc version of bash, even if you're on an Intel powered Mac! Here's how I converted to a newer, Intel compiled version.

I installed a newer bash through Fink; the latest version is in the unstable tree, so you may have to modify your Fink config file. Once that's done, just type fink install bash to install. Since I wanted to be able to switch to the old version of bash, if need be, I created a symlink here:
ln -s /sw/bin/bash /usr/bin/bash
Then I updated my NetInfo profile to use /usr/bin/bash as the default shell (which in turn specifies the default shell to /usr/bin/login). I used the GUI NetInfo Manager, but you could use nicl and niutil commands if you're brave. So if something should go wonky with the 'unstable' version of bash, I can login remotely, change the symlink /usr/bin/bash from /sw/bin/bash back to the default of /bin/bash.

One could also change the Terminal preference to call the symlink, instead of using NetInfo to modify /usr/bin/login -- but the NetInfo way feels more canonical. Now type bash --version, and you should have (assuming an Intel-powered Mac) GNU bash, version 3.00.0(1)-release (i386-apple-darwin8.7.1), a whole point update, and Intel native!
    •    
  • Currently 2.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[16,341 views]  

10.4: Update to a newer bash shell | 22 comments | Create New Account
Click here to return to the '10.4: Update to a newer bash shell' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Update to a newer bash shell
Authored by: ender3 on Sep 06, '06 08:02:53AM

Despite the fact that it is labeled as a powerpc executable, Activity Monitor reports that the installed version of bash is, indeed, running natively.



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: jhf on Sep 06, '06 08:06:31AM

The Apple supplied bash is a universal binary:

[jhf@Palmyra jhf]$ file $(which bash)
/bin/bash: Mach-O universal binary with 2 architectures
/bin/bash (for architecture i386): Mach-O executable i386
/bin/bash (for architecture ppc): Mach-O executable ppc

Bash 3 is nice though -- it has the perlesque =~ operator and backreferences.



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: ghay on Sep 06, '06 08:10:55AM

Flamewar!!!

Just use tcsh



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: tforrest on Sep 06, '06 09:49:01AM

or better: zsh



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: enderai on Sep 06, '06 12:23:36PM

or better: fish

(no, just kidding. whatever floats your boat, man...)



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: aaronrp on Sep 06, '06 04:41:24PM
I had no idea there really was a "fish" shell.

http://lwn.net/Articles/136232/

Now I want to make up my own shell acronyms.

Terribly Ugly Shell (tush)
Amicable Shell (amish)
Intelligent Reentrant Interactive Shell (irish)

And of course, the

Massively And Creatively Intelligent Newly-Tailored Optimum Shell
(macintosh)!


[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: vykor on Sep 06, '06 08:17:05AM

The "powerpc" in the version string is most likely indicative of the build machine - as in, the bash binary was (cross-)compiled on a PowerPC box. It is good practice to always use the file or lipo commands to detect the architecture of a given executable, rather than examining arbitrary compile-time strings.

You should consider using bash 3.1 (and apply all available patches) if you're going to upgrade anyway.



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: jvl001 on Sep 06, '06 08:50:06AM

For example, the command line command:
file `which bash`

in 10.4 returns:

/bin/bash: Mach-O universal binary with 2 architectures
/bin/bash (for architecture i386): Mach-O executable i386
/bin/bash (for architecture ppc): Mach-O executable ppc



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: chleuasme on Sep 06, '06 09:37:42AM

why not edit the file /etc/shells
and then choose the right one in Netinfo Manager

didn't understand the trick with the symlink in fact


and for the version running, you can althought simply type ^-x ^-v



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: JadeNB on Sep 06, '06 09:56:16AM

Darwinports has bash 3.1.17 (which, if I remember my version history correctly, includes the fabulously useful kind of brace expansion which converts {1..5} to 1 2 3 4 5; whereas bash 3.0.00 does not).



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: wgscott on Sep 06, '06 01:22:09PM

You don't have to make any symbolic links.

Just issue the command


chsh -s /sw/bin/bash




[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: sjk on Sep 06, '06 01:45:25PM
Just issue the command chsh -s /sw/bin/bash
With that method any references to /bin/bash will still use the original version.

[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: wgscott on Sep 06, '06 02:49:23PM

Exactly.

System scripts that use bash (and sh, which is bash), might be dependent upon the older versions.

But exactly the same objection can be made if you put the symlink in to /usr/bin/bash. Those scripts will still run the copy in /bin.



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: chleuasme on Sep 06, '06 05:06:34PM
anyway, I'm not sure the shell really changed with the symlink method below ; bash --version give the answer of the first bash found int the PATH, not the running shell
that's why the autor should prefer ^-x ^-v for his tests, or echo $SHELL

I tried your command but I can't get any result (I cleaned my /etc/shells before of my /opt/local/bin/bash addition, and reset Netinfo to /bin/bash)
I suppose it's the same that what I proposed before

[ Reply to This | # ]

10.4: Update to a newer bash shell
Authored by: sjk on Sep 06, '06 07:07:26PM
System scripts that use bash (and sh, which is bash), might be dependent upon the older versions.
Yep. My point was that if you want scripts (or whatever) to access a newer version then the /bin originals need to be replaced (with copies and/or links). [btw, any clue why bash and sh aren't hard linked in /bin?]

But exactly the same objection can be made if you put the symlink in to /usr/bin/bash. Those scripts will still run the copy in /bin.
True. For minimal intrusion in reserved system directories I'd rather install a new version of any shell in /usr/local/bin, /opt/local/bin, or /sw/bin instead of /usr/bin. Then optionally replace /bin originals (after preserving backups) with symlinks, knowing there's some risk of them being overwritten by Software Update. And likely not need to fuss with NetInfo or chsh, unless switching to a different shell.

[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: wgscott on Sep 06, '06 09:46:57PM
The reason they are copies and not hard links has to do with the HFS+ file system. Hard links exhibit some pathological behaviors. This is explained in a cheerfully snarkish dialog

[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: JadeNB on Sep 07, '06 09:08:22AM

Thanks so much for posting this link. I was wondering about this strange behaviour, but thought I (being relatively new to Unix) must just be doing something wrong.



[ Reply to This | # ]
10.4: Update to a newer bash shell
Authored by: wgscott on Sep 06, '06 10:08:08PM
10.4: Update to a newer bash shell
Authored by: wgscott on Sep 06, '06 10:10:18PM

Another bizarre thing I noticed once about links and shells. Back before ksh was included on os x, if I needed ksh in a script, I found a hard link to zsh worked but a symbolic link caused errors in the script. The zsh manual says a soft link should be fine, but it wasn't.



[ Reply to This | # ]
Awesome, fixed double-slash problem
Authored by: lullabud on Sep 06, '06 05:48:31PM

Awesome, I was looking for a way to change my shell on a remote Mac. Now I can cd into crazy path names without ending up with double-slashed special characters!



[ Reply to This | # ]
Netinfo changes not nessary
Authored by: mazatty on Sep 07, '06 10:29:19AM
i just installed bach 3.1.17(1)-release with darwinports. poped open a new term and typed bash --version and the new version came up.

[ Reply to This | # ]
Netinfo changes not nessary
Authored by: lihtox on Sep 07, '06 01:56:04PM

>i just installed bach 3.1.17(1)-release with darwinports. popped open a new term and typed bash --version and the new version came up.

Careful! Typing "bash --version" simply calls the first instance of bash in your path (apparently you have /opt/local/bin before /usr/bin in your path); it doesn't tell you which version of bash is currently running. You can do that via

echo $BASH_VERSION



[ Reply to This | # ]