Korn Shell Comes to OS X!

Cooknn

macrumors 68020
Original poster
Aug 23, 2003
2,111
0
Fort Myers, FL
Anybody else excited to hear about the Korn Shell's debut in Mac OS X Tiger? I cut my teeth with UNIX on an IBM RS/6000 running AIX. Did time in Atlanta and Tampa at IBM's training facilities, etc. All I've ever known is the Korn shell, until I switched to Mac OS X in November of 2003.

Can we read anything into this addition into OS X? Could Apple be doing this to satisfy IBM? I can't help but wonder if IBM didn't get out of the x86 business so that they could focus on a new division built around the PPC. The IBM Mac :eek: Could they even do that and stay within the terms of their agreement with Lenovo?
 

kg9ov

macrumors member
Feb 12, 2005
73
0
In front of a computer...
I agree, ksh is certainly a welcome addition to the list of shells included in Tiger. Personally, I don't think that there is any hidden message to be seen here though. ksh is one of the more popular shells on a wide variety of UNIX-based systems.

I am also very happy to see the enhancements to other CLI utilities (cp, mv, tar, rsync, etc.) to properly handle resource forks.

-Tony
 

grapes911

Moderator emeritus
Jul 28, 2003
6,943
3
Citizens Bank Park
I really hated ksh on linux. It just seems very 'odd' to me. I do like the fact that they are putting it in tiger though. It makes os x more unix-like to have more shell options. I hope isn't not the default, and I hope they didn't get rid of bash.
 

jim.

macrumors 6502
Dec 22, 2004
308
0
C-ville, VA
Depends on the ksh they use. I'm getting lazy now, and love my tab completion. I know I can keybind tab to cmd completion in the rc file, but again... laziness. Think it is ksh93 going in?

Jim
 

Logik

macrumors 6502a
Apr 24, 2004
616
0
personally I prefer zsh... which i believe is already included in OS X.. however if it wasn't then i musta added it myself :p
 

kg9ov

macrumors member
Feb 12, 2005
73
0
In front of a computer...
grapes911 said:
I really hated ksh on linux. It just seems very 'odd' to me. I do like the fact that they are putting it in tiger though. It makes os x more unix-like to have more shell options. I hope isn't not the default, and I hope they didn't get rid of bash.
According to this page, bash is still there and is still the default.

http://www.apple.com/macosx/features/unix/

jim. said:
Depends on the ksh they use. I'm getting lazy now, and love my tab completion. I know I can keybind tab to cmd completion in the rc file, but again... laziness. Think it is ksh93 going in?

Jim
From the sidebar at the link above:
"Korn Shell - Run scripts written for Sun Solaris more easily via AT&T’s ksh."

My guess would be it is AT&T's ksh93. It has been publicly available for a few years now.

http://www.kornshell.com/

-Tony
 

Westside guy

macrumors 603
Oct 15, 2003
5,386
2,208
The soggy side of the Pacific NW
jim. said:
Depends on the ksh they use. I'm getting lazy now, and love my tab completion. I know I can keybind tab to cmd completion in the rc file, but again... laziness. Think it is ksh93 going in?
Bash and (somewhat later) tcsh have had tab completion for a long time - are you saying Korn doesn't?

grapes911 said:
I really hated ksh on linux. It just seems very 'odd' to me. I do like the fact that they are putting it in tiger though. It makes os x more unix-like to have more shell options. I hope isn't not the default, and I hope they didn't get rid of bash.
That would be very surprising. In most every way OS X has been moving closer to other *nixes, rather than going its own way - and bash is the default shell on most of them anymore.
 

Cooknn

macrumors 68020
Original poster
Aug 23, 2003
2,111
0
Fort Myers, FL
Westside guy said:
Bash and (somewhat later) tcsh have had tab completion for a long time - are you saying Korn doesn't?
From the KSH-93 FAQ
Q6. Does ksh support file name completion?
A6. Yes, it does. The default key binding is <ESC><ESC>
however, starting with the 'g' point release, <TAB> also works
for completion. Note, the vi users need to set -o viraw
in order to get <TAB> completion to work.
 

plinden

macrumors 68040
Apr 8, 2004
3,969
3
bash pwnz ksh

Not that I know a lot about ksh - I'm just used to bash and wouldn't want to change.
 

kg9ov

macrumors member
Feb 12, 2005
73
0
In front of a computer...
Westside guy said:
That would be very surprising. In most every way OS X has been moving closer to other *nixes, rather than going its own way - and bash is the default shell on most of them anymore.
Other than the various Linux distros and Mac OS, do you know of another *nix system that uses bash as the default shell? I am just curious if others have moved to bash. I have not heard of any, but that doesn't mean it didn't happen.

-Tony
 

mattraehl

macrumors 6502
Feb 26, 2005
384
1
A welcome addition, indeed!

That is good news! However, I imagine that most folks that really wanted Korn shell already compilied it (Or, for that matter, downloaded the ppc binary from AT&T's website) and has it running on their Mac. It's been free for a few years now. At work almost all of our machines are HP-UX (Hewlett-Packard Unix), which uses ksh. I couldn't stand having a different shell at home, so I installed in on my iBook. Long live ESC-ESC (or ESC-\) filename completion! :)
 

Cooknn

macrumors 68020
Original poster
Aug 23, 2003
2,111
0
Fort Myers, FL
mattraehl said:
That is good news! However, I imagine that most folks that really wanted Korn shell already compilied it (Or, for that matter, downloaded the ppc binary from AT&T's website) and has it running on their Mac. It's been free for a few years now. At work almost all of our machines are HP-UX (Hewlett-Packard Unix), which uses ksh. I couldn't stand having a different shell at home, so I installed in on my iBook. Long live ESC-ESC (or ESC-\) filename completion! :)
I guess I haven't been that ambitious (to get ksh on my Mac). I've really been away from AIX for a while, but when I was working with it I was always on an IBM3151. I have to say that I do like the DIR_COLORS in bash on my Mac. Should that work with ksh as well?
 

kg9ov

macrumors member
Feb 12, 2005
73
0
In front of a computer...
Cooknn said:
I have to say that I do like the DIR_COLORS in bash on my Mac. Should that work with ksh as well?
Are you talking about different colors for files, links, etc. in a directory listing? Someone correct me if I'm wrong (I don't use the color stuff), but isn't this handled by the ls command rather than the shell?

-Tony
 

Cooknn

macrumors 68020
Original poster
Aug 23, 2003
2,111
0
Fort Myers, FL
kg9ov said:
Are you talking about different colors for files, links, etc. in a directory listing? Someone correct me if I'm wrong (I don't use the color stuff), but isn't this handled by the ls command rather than the shell?

-Tony
DIR_COLORS lives in /etc and it kicks off in my .bashrc so I assume it's handled by the shell.
 

Westside guy

macrumors 603
Oct 15, 2003
5,386
2,208
The soggy side of the Pacific NW
kg9ov said:
Other than the various Linux distros and Mac OS, do you know of another *nix system that uses bash as the default shell? I am just curious if others have moved to bash. I have not heard of any, but that doesn't mean it didn't happen.
Well, actually, now that I've done some digging... :D

Here at UW the default shell on all sorts of OSes (Linux, AIX, Solaris) has been set to bash - so I assumed that was the default. However for Solaris it appears the install default is bsh (Bourne), not bash (Bourne Again). And as others point out for AIX it's ksh as of 4.1 (and bsh prior to that).

I thought the BSDs were all doing bash now, but my BSD-loving coworker is out of the office right now so I can't check that.

Edit: Nope. Depending on the flavor of BSD it's either bsh, csh, or ksh. Figures. :D
 

kg9ov

macrumors member
Feb 12, 2005
73
0
In front of a computer...
Westside guy said:
Well, actually, now that I've done some digging... :D

Here at UW the default shell on all sorts of OSes (Linux, AIX, Solaris) has been set to bash - so I assumed that was the default. However for Solaris it appears the install default is bsh (Bourne), not bash (Bourne Again). And as others point out for AIX it's ksh as of 4.1 (and bsh prior to that).

I thought the BSDs were all doing bash now, but my BSD-loving coworker is out of the office right now so I can't check that.

Edit: Nope. Depending on the flavor of BSD it's either bsh, csh, or ksh. Figures. :D
OK, I didn't have time to go researching it earlier. I know HP-UX does not have bash by default and I thought most of the other major Unix OSs were also still using sh, ksh, or csh.
 

jim.

macrumors 6502
Dec 22, 2004
308
0
C-ville, VA
I've always seen old korn shells on Solaris machines. When I was in college, the Sun machines ran ksh88 (which btw does NOT have tab completion), and I just set it to run bash on login. Here at UVA, it also runs ksh88 apparently. No tab completion. Hence my comment above.

For my chem work, we used IRIX machines, and those were set to tcsh, but I believe that was a custom shell setting. Then I found bash, and loved the simplicity of its scripting so it kind of stuck with me. Now I'm just spoiled and lazy.

Jim
 

kg9ov

macrumors member
Feb 12, 2005
73
0
In front of a computer...
jim. said:
I've always seen old korn shells on Solaris machines. When I was in college, the Sun machines ran ksh88 (which btw does NOT have tab completion), and I just set it to run bash on login. Here at UVA, it also runs ksh88 apparently. No tab completion. Hence my comment above.
Well, it could be worse. You could have been stuck with the Bourne shell that comes with Solaris. :eek:

-Tony
 
Cooknn said:
I guess I haven't been that ambitious (to get ksh on my Mac). I've really been away from AIX for a while, but when I was working with it I was always on an IBM3151. I have to say that I do like the DIR_COLORS in bash on my Mac. Should that work with ksh as well?

what do I have to do to set up DIR_COLORS? I guess I didn't know about it but it sounds useful. I use bash on 10.3.
 

mattraehl

macrumors 6502
Feb 26, 2005
384
1
Cooknn said:
I guess I haven't been that ambitious (to get ksh on my Mac). I've really been away from AIX for a while, but when I was working with it I was always on an IBM3151. I have to say that I do like the DIR_COLORS in bash on my Mac. Should that work with ksh as well?
For BSD-based UNIX systems, ls -G gives you colors, and the color settings come from an environment variable, it's either LSCOLORS or LS_COLORS, I'm not at my machine so I can't verify. The ls man pages give the name of the variable, and how to configure it. So I just do alias ls='ls -G' and define LSCOLORS in my .profile.
 

Cooknn

macrumors 68020
Original poster
Aug 23, 2003
2,111
0
Fort Myers, FL
mattraehl said:
For BSD-based UNIX systems, ls -G gives you colors, and the color settings come from an environment variable, it's either LSCOLORS or LS_COLORS, I'm not at my machine so I can't verify. The ls man pages give the name of the variable, and how to configure it. So I just do alias ls='ls -G' and define LSCOLORS in my .profile.
Thanks Matt :)
anonymous161 said:
what do I have to do to set up DIR_COLORS? I guess I didn't know about it but it sounds useful. I use bash on 10.3.
Turns out I'm not using DIR_COLORS at all :eek: I must have been experimenting with it before I figured out that all I needed to do was add alias ls='ls -G' to my /etc/bashrc
Can't remember though, where I defined the non-standard color attributes :confused:
 

mattraehl

macrumors 6502
Feb 26, 2005
384
1
custom ls colors

This is from the ls man pages:

LSCOLORS The value of this variable describes what color to use
for which attribute when colors are enabled with
CLICOLOR. This string is a concatenation of pairs of the
format fb, where f is the foreground color and b is the
background color.

The color designators are as follows:

a black
b red
c green
d brown
e blue
f magenta
g cyan
h light grey
A bold black, usually shows up as dark grey
B bold red
C bold green
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background

Note that the above are standard ANSI colors. The actual
display may differ depending on the color capabilities of
the terminal in use.

The order of the attributes are as follows:

1. directory
2. symbolic link
3. socket
4. pipe
5. executable
6. block special
7. character special
8. executable with setuid bit set
9. executable with setgid bit set
10. directory writable to others, with sticky bit
11. directory writable to others, without sticky
bit

The default is "exfxcxdxbxegedabagacad", i.e. blue fore-
ground and default background for regular directories,
black foreground and red background for setuid executa-
bles, etc.


Upon digging deeper, I found out that the alternative to defining the alias ls='ls -G' is setting the environment variable CLICOLOR=1. If CLICOLOR=1, ls will give colors, whether you give ls -G or just ls.
:D
 

HiRez

macrumors 603
Jan 6, 2004
5,805
1,700
Western US
I'm still using tcsh, is there something I'm missing by not switching to bash or ksh? I'm not doing anything fancy, just some basic CL stuff.
 

mattraehl

macrumors 6502
Feb 26, 2005
384
1
not really

HiRez said:
I'm still using tcsh, is there something I'm missing by not switching to bash or ksh? I'm not doing anything fancy, just some basic CL stuff.
Unless you're writing actual shell scripts, not just entering comands at the prompt, there really aren't huge differences between any of the major shells. In fact, if you are just doing basic shell scripts, you won't even notice much difference between bash and ksh, since they are both something like 99% bourne shell (sh) backwards-compatible. But, C-style shell languages (tcsh, csh) are very different when it comes to scripting. Their scripting language is more like C, which was supposed to be a good thing, but in my opioning it just ends up kind of messy. But some people love their C shells.
 

HiRez

macrumors 603
Jan 6, 2004
5,805
1,700
Western US
mattraehl said:
In fact, if you are just doing basic shell scripts, you won't even notice much difference between bash and ksh, since they are both something like 99% bourne shell (sh) backwards-compatible.
Yeah, when I write scripts, I just use the !sh anyway. I'm just wondering if I should switch to bash, since it's the standard shell now. Maybe easier to get help with and run sample commands on? Does it have tab-completion of directory fragments like tcsh does though? That's probably the one feature I couldn't live without.