Exit Wiki

This shell script will look up the definition of a Mac OS Error Code. The code is based on This MacOSXHints Hint, with some modifications.

#!/bin/sh

GREP="/usr/bin/grep"

SYSLIBFRAME="/System/Library/Frameworks"
CORESERVFRAME="$SYSLIBFRAME/CoreServices.framework"
CURRENTFRAME="$CORESERVFRAME/Versions/Current/Frameworks"
CARBONHEADERS="$CURRENTFRAME/CarbonCore.framework/Headers"

$GREP -- "$1," $CARBONHEADERS/MacErrors.h 

Requires the developer tools installed.

Save it in a file somewhere (named, for example 'errorCodeShellScript') and off you go

To Use:

errorCodeShellScript -60

BBEdit Unix Filter Version

I also created a version that runs as a BBEdit filter. This version requires some extra work, because BBEdit passes filters a file that contains the selection, instead of the selected values directly. This makes sense of course, it just adds some code.

#!/bin/sh

GREP="/usr/bin/grep"

SYSLIBFRAME="/System/Library/Frameworks"
CORESERVFRAME="$SYSLIBFRAME/CoreServices.framework"
CURRENTFRAME="$CORESERVFRAME/Versions/Current/Frameworks"
CARBONHEADERS="$CURRENTFRAME/CarbonCore.framework/Headers"

{ 
        read lookfor
} < "$1"
$GREP -- "$lookfor," $CARBONHEADERS/MacErrors.h 

The major difference is the read block, where I put the contents of the passed file into a variable, then pass that variable to grep.

Save it in the Unix Filters folder in the Unix Support folder of the BBEdit Support folder.

To Use the BBEdit Filter version:

Enter the error code in a BBEdit window (for example, enter "-43" then select it), then choose the filter.

The filter will return the error code definition if one can be found, and nothing if there is no such error code.

Mac OS Error Code Shell Script (last edited 2006-10-13 16:07:11 by RyanWilcox)