Bash weirdness on Mac OS X Intel boxes

Just a quickie (to prevent my blog from becoming a dinosaur and eventually fossil fuel…)

If you’re running bash on an Intel Mac you might see some interesting behavior if you inspect the shell’s variables:

[jwight@ratatosk] jwight$ set | grep TYPE
HOSTTYPE=powerpc
MACHTYPE=powerpc-apple-darwin8.0
OSTYPE=darwin8.0

PowerPC? Darwin 8.0? On my Quad G5 I get identical results. Checking the bash binary with the ‘strings’ command seems to show these values are hardcoded:

[jwight@ratatosk] jwight$ strings which bash | grep powerpc
powerpc-apple-darwin8.0
powerpc

Looks like the OS version and the processor type is hardcoded into bash.

Oh and for the record this is what ‘uname’ reports:

[jwight@ratatosk] jwight$ uname -a
Darwin ratatosk 8.6.1 Darwin Kernel Version 8.6.1: Tue Mar  7 16:55:45 PST 2006; root:xnu-792.9.22.obj~1/RELEASE_I386 i386 i386

This entry was posted in Uncategorized and tagged . Bookmark the permalink.
  • derek

    Just noticed that myself. Very bizarre on Apple’s part. Hopefully they’ll fix that one of these days.

  • derek

    Just noticed that myself. Very bizarre on Apple's part. Hopefully they'll fix that one of these days.

  • chris

    Still broken as of Oct. 20th, 2006. This is a Mac Pro running 10.4.8.

    $ uname -a Darwin delices 8.8.1 Darwin Kernel Version 8.8.1: Mon Sep 25 19:42:00 PDT 2006; root:xnu-792.13.8.obj~1/RELEASE_I386 i386 i386 $ set | grep -i type HOSTTYPE=powerpc MACHTYPE=powerpc-apple-darwin8.0 OSTYPE=darwin8.0

    I’m more annoyed by the i386 kernel, personally.

  • chris

    Still broken as of Oct. 20th, 2006. This is a Mac Pro running 10.4.8.<br><br>$ uname -a<br>Darwin delices 8.8.1 Darwin Kernel Version 8.8.1: Mon Sep 25 19:42:00 PDT 2006; root:xnu-792.13.8.obj~1/RELEASE_I386 i386 i386<br>$ set | grep -i type<br>HOSTTYPE=powerpc<br>MACHTYPE=powerpc-apple-darwin8.0<br>OSTYPE=darwin8.0<br><br>I'm more annoyed by the i386 kernel, personally.

  • stephen bigelis

    Ha I just noticed this as well on my mac book pro.

  • stephen bigelis

    Ha I just noticed this as well on my mac book pro.

  • Leo

    I did, too. $uname -a Darwin Computer.local 8.9.1 Darwin Kernel Version 8.9.1: Thu Feb 22 20:55:00 PST 2007; root:xnu-792.18.15~1/RELEASE_I386 i386 i386

    $set | grep -i type HOSTTYPE=powerpc MACHTYPE=powerpc-apple-darwin8.0 OSTYPE=darwin8.0

  • Leo

    I did, too. <br>$uname -a<br>Darwin Computer.local 8.9.1 Darwin Kernel Version 8.9.1: Thu Feb 22 20:55:00 PST 2007; root:xnu-792.18.15~1/RELEASE_I386 i386 i386<br><br>$set | grep -i type<br>HOSTTYPE=powerpc<br>MACHTYPE=powerpc-apple-darwin8.0<br>OSTYPE=darwin8.0

  • robthebrew

    On a Mac Pro: uname -a Darwin computer.local 8.9.2 Darwin Kernel Version 8.9.2: Thu Feb 22 18:08:23 PST 2007; root:xnu-792.19.2~1/RELEASE_I386 i386 i386

    machine i486

    set | grep TYPE HOSTTYPE=powerpc MACHTYPE=powerpc-apple-darwin8.0 OSTYPE=darwin8.0

    So nowhere is there any mention of x86-64. that really throws a spanner in the works for porting 64b apps.

  • robthebrew

    On a Mac Pro:<br>uname -a<br>Darwin computer.local 8.9.2 Darwin Kernel Version 8.9.2: Thu Feb 22 18:08:23 PST 2007; root:xnu-792.19.2~1/RELEASE_I386 i386 i386<br><br>machine<br>i486<br><br>set | grep TYPE<br>HOSTTYPE=powerpc<br>MACHTYPE=powerpc-apple-darwin8.0<br>OSTYPE=darwin8.0<br><br><br>So nowhere is there any mention of x86-64. that really throws a spanner in the works for porting 64b apps.

  • http://www.unlock-the-iphone.com Unlockiphone

    I often need to install OSs on Intel boxes, which frequently come without CDs or floppy these days. After some playing, here is how I use my PowerBook running OS X to do the job via pxeboot. The following example shows OpenBSD as the OS to install on the Intel box.

  • http://brunerd.com/blog brunerd

    Yes, I have noticed this… (took me a while eh?) this is only on Tiger intel builds

    You can add this in /etc/profile:
    HOSTTYPE=i386
    MACHTYPE=i386-apple-darwin8.0
    export HOSTTYPE
    export MACHTYPE

    You can also go into bash with a hex editor and change the first two instances of powerpc, (the second set is the ppc portion of the universal binary) with the extra space leftover just pad it with zeros.