Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am working on some bash shell scripting for a local login script and it works fine on Leopard and Snow Leopard but fails on Lion. I was curious if there was a place that listed the differences in bash on Lion?

share|improve this question
5  
This is a very, very vague question. You'd do best to post all or a portion of the script and explain what you're trying to do. –  macaco Nov 3 '11 at 22:36
    
I do not think that it required a down vote. Surely there is a way to tell what differences exist in BASH between the versions. –  John Nov 3 '11 at 22:46
    
I was trying to use the following variable in my bash script: username="$(whoami)" –  John Nov 3 '11 at 23:00
1  
@John I tried u="$(whoami)"; echo $u on 10.6 and 10.7, with the same result. Post the script source, that way you'll get decent answers. Also, to address your main question, the latest system upgrades for 10.7 and 10.6 will have the same version of bash anyway, ie. 3.2.48(1)-release –  Slomojo Nov 3 '11 at 23:06
add comment

2 Answers

up vote 5 down vote accepted

Within bash, the command echo $BASH_VERSION shows the version of bash. You can then look up what changed in the changelog file, which is bash's case is called CHANGES. (There's a more complete changelog in the sources, but it's mainly of interest to people who write and maintain bash.)

If your machines are up-to-date, they'll be running the same version. Make sure all the external programs used in the script are up-to-date too: the script may behave differently because one of these programs produces different output.

You can watch what your script is doing more closely by running bash -x /path/to/script. The -x option makes bash print a trace for each command that it runs. You can also put set -x in a script to turn tracing on, and set +x to turn it off.

share|improve this answer
1  
bash --version will give you the same result as echo $BASH_VERSION btw. +1 for bash -x script –  Slomojo Nov 6 '11 at 22:10
add comment

Assuming a SnowLeopard or Lion installation that has the latest software updates, the version of Bash is the same. 3.2.48(1)-release.

On SnowLeopard you may have a 32bit compilation in some cases, whereas on Lion it is (by default) 64bit.

The command username="$(whoami)" is extemely unlikely to ever change it's output on bash, since doing so would incur the fast moving, brain devouring wrath of an infinite number of ravenous zombie sysadmin types.

(By the way sysadmins are almost never undead, despite the occasional appearance to the contrary. The description was added for dramatic effect, and no offence to sysadmins was intended. I offer my heartfelt apology to any actual undead sysadmins, and their families, and I urge them to grab a shotgun immediately and barricade the bedroom door, double tap to be sure.)

share|improve this answer
    
+1 for a good answer and including undead sysadmins. –  styfle Nov 4 '11 at 6:22
1  
+1 for undead sysadmins, too! :D –  Asmus Nov 4 '11 at 10:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.