• set -e and set -x

    If you write shell scripts, you definitely need to know about two nice features that can be enabled through the set builtin:set -e: Enables checking of all commands. If a command exits with an error and the caller does not check such error, the script aborts immediately. Enabling this will make your scripts more robust. But don't wait until your script is "complete" to set the flag as an afterthought, because it will be a nightmare to fix the scrip to work with this feature enabled. Just write set -e as the very first line of your code; well... after the shell bang.set -x: If you are writing simple scripts that are meant to, well, script the execution of a few tasks (as opposed of being full-flown programs written in shell), set this flag to trace the execution of all commands. This will make the interpreter print each command right before it is executed, so it will aid you in knowing what is happening at any point in time.Subscribe to the Julipedia to stay tuned on posts similar to this one and read more about this blog to see what you may be missing! [Continue reading]

  • Installing NetBSD/macppc on a Mac Mini G4

    Yesterday, I spent a while installing NetBSD/macppc 5.0.1 on a Mac Mini G4. The process wasn't easy, as it involved the following steps. I'm omitting many details, as they are "common knowledge" to Mac users (or otherwise can be easily found on the net):After booting the installer from the CD image, drop into the shell.Use pdisk to create an Apple_HFS partition for the boot loader and two Apple_UNIX_SVR2 partitions, one for the root file system and another for swap.Run sysinst and install the system. When asked to repartition the disk, just say Use existing partition sizes.Once the system is installed, drop again into the shell before rebooting.Mount your hard disk into /mnt and chroot into it.Fetch a copy of pkgsrc.Install the sysutils/hfsutils package.Use hformat to create a new HFS file system in the Apple_HFS partition we created.Mount the installation CD.Copy, using hcopy, the ofwboot.xcf file from the CD to the boot partition.Reboot.Drop into the OpenFirmware setup (Command+Option+P+R).Set boot-device to hd:,ofwboot.xcf.Set boot-file to netbsd.And here is the tricky thing to get the machine to auto-boot: Set boot-command to ." hello" cr " screen" output boot, not mac-boot.I found the last command somewhere on the Internet (dunno where now), but, supposedly, a regular mac-boot should have worked. In fact, it works if you call this command from the prompt, but not during automatic boot. (It turns out to be a problem with the version of OpenFirmware I have.)Just writing down the steps in case I need them later on. Installing Debian stable was much, much easier, but the installer for testing crashes every day with a different error, so I gave up.(Oh, by the way, I did the same installation into an old PowerMac G3 and that was really painful. The machine refused to boot from any of the CDs I tried and the prebuilt kernels hang during initialization due to a bogus driver. In the end: netbooting and using custom kernels.) [Continue reading]