I have a Mac because you get nice easy-peasy pretty stuff and proper Unix all in the same machine. Some days when you crack open the terminal you feel a great sense of power and flexibility. Other days you want to strangle the people responsible for Unix. (Anybody for a bring-back-VMS campaign ?)
I use iTerm rather than the Mac-supplied Terminal. It has stopped development, so today I updated to the successor project, imaginatively entitled iTerm2 (strongly recommended – check it out). Suddenly a whole bunch of my alias-ed commands bombed. For example, to check what tunnels I have running I type “tunnels” defined as
alias tunnels=’ps -uaxww | grep ssh’
This gave an error message along the lines of “no such user” whereas when I re-started the old iTerm, it still worked. I narrowed this down to “ps -u” behaving differently in the two apps. In the old iTerm this adds a column to a ps listing which shows the UID owner of processes; in the new iTerm2 the -u switch is for filtering by UID, and so the command expects you to specify that UID. (The regular Mac Terminal behaves the same).
I thought I must be going crazy. In both cases I was simply running a dumb terminal, with the same login command, running the same shell, on the same hardware, running the same version of unix, issuing the same very simple unix command. Wuh ?????
After much hair tearing and some Googling, I found this blog post. It seems that the problem is an environment variable called COMMAND_MODE. When iTerm starts a terminal it sets this to “legacy” whereas iTerm2 and Terminal set it to “unix2003”.
Unix03 is an attempt at Unix standardisation by a body called the Open Group (see here). The other standardisation attempt is POSIX. According to this article no Linux or BSD vendor has achieved full compliance.
So… typical dilemma … do I leave my stuff as it is and set COMMAND_MODE=legacy, or do I try to update my stuff ?
Anyhoo. Sorry for boring you, but ain’t that just bloody typical unix ?