Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 08-23-2002, 02:01 PM   #1
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
I am Bourne Again!

I'll let my 10.2 Terminal window speak for me:

[thermodynamics:~] mikey% bash
bash-2.05a$ Yay!
bash: Yay!: command not found
bash-2.05a$ exit
[thermodynamics:~] mikey%

:-D

Bash is included with 10.2! Rejoice.


-/-
Mikey-San
Mikey-San is offline   Reply With Quote
Old 08-23-2002, 03:50 PM   #2
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
Re: I am Bourne Again!

Quote:
Originally posted by Mikey-San
Bash is included with 10.2! Rejoice.

Ahhh, so that's why nobody listens to me when I say use bash instead of tcsh! I have forgotten about installing bash and assumed it came with OS X. Great news that it's bundled with 10.2! Pity though that Apple didn't make it default. Now tcsh will continue to lure newbies into scripting with it.
__________________
/PEZ
osxpez is offline   Reply With Quote
Old 08-23-2002, 06:10 PM   #3
stetner
MVP
 
Join Date: Jan 2002
Location: Brisbane, Australia
Posts: 1,108
Anyone know if ksh is there in 10.2 ?
__________________
Douglas G. Stetner
UNIX Live Free Or Die
stetner is offline   Reply With Quote
Old 08-23-2002, 07:49 PM   #4
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
yes. ksh is not there in 10.2
mervTormel is offline   Reply With Quote
Old 08-24-2002, 07:47 PM   #5
hombre
Triple-A Player
 
Join Date: Jul 2002
Location: Chicago
Posts: 81
So, is sh still zsh or is it bash now?
hombre is offline   Reply With Quote
Old 08-24-2002, 07:51 PM   #6
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
sh is bash now
mervTormel is offline   Reply With Quote
Old 08-25-2002, 02:39 PM   #7
dm2243
Triple-A Player
 
Join Date: Jun 2002
Posts: 68
Jaguar ...and Python too!

Code:
% whereis python
/usr/bin/python
(of course, not everyone will jump for joy as a result...hello, pmccann)
dm2243 is offline   Reply With Quote
Old 08-27-2002, 11:47 AM   #8
below
Triple-A Player
 
Join Date: Aug 2002
Location: Germany
Posts: 108
Question Why use bash?

Could someone please explain in a nutshell (pun intended), what makes bash better than tcsh.
Yes, I too was lured to tcsh, and I like things like the dictionary, auto completion, history and such.

So, what's the deal?

Alex
below is offline   Reply With Quote
Old 08-27-2002, 12:00 PM   #9
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
Talking Csh Programming Considered Harmful

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
mervTormel is offline   Reply With Quote
Old 08-27-2002, 12:23 PM   #10
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
The thing is that since tcsh is such a Crappy Scripting Tool (tm) (see merv's post above) most of latest years shell development has gone into sh and ksh derivates like bash and zsh and what have you. Bash was early on bundled and default shell for most Linux dists so there's lots and lots of bash knowledge out there.

Besides bash is a blend between the tcsh's excellent interactive features and the ksh's excellent scripting model. So you won't miss out on anything when you switch to bash.
__________________
/PEZ
osxpez is offline   Reply With Quote
Old 08-27-2002, 12:37 PM   #11
pmccann
Major Leaguer
 
Join Date: Jan 2002
Location: Adelaide, South Australia
Posts: 470
Re: ...and Python too!

Quote:
Originally posted by dm2243
Code:
% whereis python
/usr/bin/python
(of course, not everyone will jump for joy as a result...hello, pmccann)

Cool: thanks for the heads up. While I don't use python much (indeed, barely at all...), and always enjoy a little good-natured ribbing with its prophets, it's good to know that python is standard in 10.2. There are some *great* applications written using python (mailman jumps instantly to mind).

Let those who ride decide! (Some people enjoy auto-erotic asphyxiation; me, I haven't really travelled that particular route, and tend to let it all "hang loose". This is all about scripting languages, right?)

Cheers,
Paul
pmccann is offline   Reply With Quote
Old 08-27-2002, 01:11 PM   #12
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
Re: Re: ...and Python too!

Quote:
Originally posted by pmccann
There are some *great* applications written using python (mailman jumps instantly to mind).

And let's not forget that Python gets a lot attention these days and that many "serious" developers are deep into Python. We need some of those in the OS X camp. =)
__________________
/PEZ
osxpez is offline   Reply With Quote
Old 08-28-2002, 02:08 AM   #13
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
Re: Why use bash?

Quote:
Originally posted by below
Could someone please explain in a nutshell (pun intended), what makes bash better than tcsh...

one word: functions!

bash aliases don't handle arguments like tcsh aliases. but, tcsh doesn't have functions (AFAIK)! bash functions handle args, and a whole lot more.

bash functions are really swell. they're like aliases, but they're mini-scripts with all the structure of true sh scripts (AFAIK). they can be quite powerful. they reside in your shell variable space, so there's a little memory penalty. but speed is the trade-off.

they execute in your current shell context; no new process is created to run the function, as opposed to shell scripts. there is also local variable declaration. and they're recursive.
Code:
zfp     () {    # find process(es)

# handle multiple args by
# translating spaces to the egrep metachar |

  local ss ; ss=`echo "$@" | tr " " "|"` ;

# sort by real mem size, be 
# reasonable and display the ps header

  ps wwaxum | egrep -i "${ss}| PID %CPU " | grep -v 'egrep -i' ; 
} 

# can't do that in tcsh - ha ha

# example:

$ zfp cron inetd slpd bash
USER   PID %CPU %MEM      VSZ    RSS  TT  STAT      TIME COMMAND
merv  1002   0.0  0.1     2204   1204  p1  Ss     0:01.34 bash --login
merv  1092   3.0  0.1     2204   1164 std  Ss     0:01.22 -bash (bash)
root   362   0.0  0.0     5108    520  ??  Ss     0:07.58 slpd -f /etc/slpsa.conf
root   351   0.0  0.0     1560    132  ??  Ss     0:00.21 cron
root   299   0.0  0.0     1288    116  ??  Ss     0:00.01 inetd
Tuck function zfp into your bash startup.
mervTormel is offline   Reply With Quote
Old 08-28-2002, 03:01 AM   #14
pmccann
Major Leaguer
 
Join Date: Jan 2002
Location: Adelaide, South Australia
Posts: 470
Next...

Come on mT. With such a lovely template to work from it was a pleasure to render your claim ("# can't do that in tcsh - ha ha") false!

Try chucking the following single line into your .cshrc.

alias zfp 'set ss=`echo "\!*" | tr " " "|"`;ps wwaxum|egrep -i "${ss}| PID %CPU
"|grep -v "egrep -i"'

Shell scripting in csh/tcsh may be a bit *nasty*, but aliases are still pretty useful. Indeed, as an interactive shell I think tcsh is really nice.

Cheers,
Paul

ps While it *looks* like I'm an apologist for tcsh, I am in the process of changing allegiances to the "ta da" (drum roll please) Z-shell. Looks like lots of fun. (So does bash, but it's already got enough friends!)
pmccann is offline   Reply With Quote
Old 08-28-2002, 03:12 AM   #15
osxpez
Major Leaguer
 
Join Date: May 2002
Location: Sweden
Posts: 282
Re: Re: Why use bash?

Quote:
Originally posted by mervTormel
one word: functions!

Functions is a major thing. But there's more. There's actually a few things that the tcsh does that bash doesn't (like spell checking and tty sanity checking). Maybe spell checking can be added by user defined functions, but it's not built in and thus not widely available. But hey! You can always use zsh. zsh is very ksh (or POSIX sh) compatible and has all interactive bells and whistles you could ask for. But I stick to bash, because that's the main stream and for once I have decided to go with the flow.

Check the comp.unix.shell "What shell?" FAQ

It has a brief history of shells and a feature comparison table.
__________________
/PEZ
osxpez is offline   Reply With Quote
Reply


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 On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 10:35 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.