MACSCRPT Archives

August 2007

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bill Briggs <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 3 Aug 2007 12:44:57 -0300
Content-Type:
text/plain
Parts/Attachments:
text/plain (37 lines)
At 12:19 AM -0400 8/3/07, David Livesay wrote:
>If you started out with OS X beta you got tcsh as your default shell.

 I didn't consider the beta sufficient to be a work machine. In fact, I didn't think 10.0 was that much better, so didn't use OS X as a main work machine until 10.1 shipped.


>If you kept all your files and settings every time you upgraded your OS imported them every time you upgraded your hardware, then tcsh would still be your default shell.

 I did migrate from 10.1 on, but not from earlier versions, which I just poked around with as time allowed. I quite like some of the things bash has going for it, so am happy enough with it. But I do have to be careful about things that get run in sh (like do shell script commands).


>That's what I did. I'm pretty comfortable with it now, and I like it, but I usually write my scripts for sh so it will run anywhere. If I ever run into something where I need a bash or tcsh feature in a script, I'll use bash or tcsh, but I haven't yet.
>
>>http://www.tldp.org/LDP/abs/html/
>
>This is pretty good. He includes sh as well as bash and points out the differences. This guy should write a book.

 Here's another one
<http://learnlinux.tsf.org.za/courses/build/shell-scripting/index.html>
It's pretty good on first glance. Haven't really looked in detail at any of it.


>> There's a downloadable PDF version of it too. If you do use this, one caveat. He says that you can use the extension .sh for shell scripts. No can do. You'll need to use .bash on your Mac. Even if you specify the path to the bash shell in the first line of the file it won't use bash without the file extension. This will cause some examples to fail. So just keep that file extension in mind as you go and it'll work just fine.
>
>I generally omit the extension unless it's mandated, like monthly.local or weekly.local, for example. Most of the scripts in /usr/bin don't have extensions.

 True enough.


>>P.S. It helps to read man pages if you've had some exposure to C programming. If not, then some portions of some man pages will seem exceedingly impenetrable.
>
>I've gradually gotten to where I can interpret most man pages, but some entries are just plain useless (see man read, for example) and most of the really important things you need to write a shell script aren't documented. There's more to writing a shell script than knowing a few commands. man for, for example, tells you all about how for loops work--in Tcl.

 Ah, but you're looking in the wrong place. It is in the man page for the shell. In man bash I can find "for" documented, as well as almost anything else I need to know about scripting syntax in that shell. It's there in man sh as well, but for tcsh it looks like "foreach", not "for", is the control statement. But I don't know that shell, so can't be definitive about it.

- web

ATOM RSS1 RSS2