|
|
Use zsh to emulate ksh
what the bloomin' eck is all that about?
Background
We're talking about shells - command line interpreters. When you fire up a Terminal window, it runs a program to read in your commands and execute them; this is called a shell.
There are several different shells, each with slightly different features (automatic completion, job control, filename expansion, programming features, &c.). If you're interested in the history: the first Unix shell was called the Bourne shell, and was simply called sh (in the Unix tradition of keeping things short). It had only very basic features, so there have been several more shells since, each with new stuff. csh (the C shell) added several programming features, a little like the C programming language; tcsh (the T shell) added lots of other features on top of that. ksh (the Korn shell, written by a guy called Korn) started with the Bourne shell, and added lots of stuff in a similar way. zsh adds lots more features on top of that. And finally, the other popular shell is bash (the Bourne Again shell), which started off as the GNU project's rewrite of the Bourne shell, but has added lots of features similar to the others. The problem is that all of these shells have many similar features, but all implemented in slightly different ways and requiring slightly different syntax. So when writing very complex scripts, you either need to be very careful to use lowest-common-denominator features, or you need to specify which shell to use. Mac OS X comes with sh, bash (the default), and zsh. Unfortunately for folks who like ksh, that's proprietary, so there's no Mac OS X version. However, because zsh was based on it, you can tell zsh to pretend to be ksh, which is what this hint is about. Personally, I suggest people go the whole hog and use zsh for itself. It's similar enough to ksh that most stuff runs anyway, and people will feel at home, but it's got some really neat new features. For example, spelling correction and completion, command-line editing, shell functions, history, and my favourite: powerful recursive filename completion, which completely removes the need for a separate find command, and lets you do some really neat stuff very easily. ---
Background
The reason for linking it to ksh is that you might have scripts that run on other unix platforms written to invoke ksh. This is the case for some software I was recently compiling for OS X. So you can either hunt down and edit all of these files and debug them to ensure that they run uder zsh, and then instruct all other users on how to do it, or you can issue a 1 line command.
Background
I've been using a .zshrc file with the command "emulate ksh" in it.
Nope
Not if you have to run two different scripts, one which starts with
Background
Andy, cheers for that! The mud is clearing slightly. So basically, the higher up in the versions of shell, the more / different commands the shell will run as an interpreting environment? Cool.. I can see how that would be useful.
Background
Andy writes - |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.25 seconds |
|