A blog named for the muse of Astronomy containing musings by an astronomer

Annoyance: ksh doesn’t work on MacOS X Tiger

Posted on July 19, 2007 by Juan

After several days of trying to get the Hectospec folk’s data reduction packages working on my Mac, I realized one of the major problems was that ksh on the Macintosh had a major problem. Normally, in ksh (korn shell), you can set up a loop to read through a list of objects via a read command within a while..do loop. For example, to echo a list of files your ksh script could contain

ls -1 . | while read fname; do
  echo $fname

where the read filename bit reads a line from the piped input and assigns the first block of text (before a space) to the variable fname. Try this script on MacOS X and it produces no output. “read” fails. This has been documented elsewhere at least twice that I have been able to find with Google, here and here. So clearly, there is a serious bug in the installed version of ksh on MacOS X. I fixed it by updating my ksh using MacPorts, a simple
sudo port install ksh93

followed by changes in the Hectospec scripts to point to/opt/local/bin/ksh instead of /bin/ksh and I was done.

Leave a Reply

  • Translate

  • Astro Pic o' the Day

  • Archives

  • Admin

↑ Top