Those pesky core audio error codes

11th Mar, 2015 | unix xcode

We've all been there. I was there recently with an error code from core audio, '-66748' to be specific. On a good day the meaning for these codes can be found in the core audio header files but this must be done by hand, unless there is some framework global search facility in XCode that no-one has told me about.

This time I thought I'd be slightly more automated and grep the framework header directory to search everything for me.

So with a right click on the framework and "Show in Finder" to get the path I tried

grep -r "-66748" /Applications/

grep: warning: recursive search of stdin


I've specified the path so why is grep reading stdin?

Turns out it's the negative error code, despite being in quotes. The dash is making -66748 a grep argument, rather than the search term.

The trick to fix this is to use a double dash — to indicate to the shell there are no further optional arguments to parse after the -r option.

This comes up with the goods:

grep -r -- "-66748" /Applications/

/Applications/ kAudioComponentErr_NotPermitted = -66748,

and a bit of extra grep arguments to show line numbers and context:

grep -nr -C 2 -- "-66748" /Applications/

/Applications/ kAudioComponentErr_TooManyInstances = -66750,

/Applications/ kAudioComponentErr_InstanceInvalidated = -66749,

/Applications/ kAudioComponentErr_NotPermitted = -66748,

/Applications/ kAudioComponentErr_InitializationTimedOut = -66747,

/Applications/ kAudioComponentErr_InvalidFormat = -66746

Or why not put it in a script?


if [ "$#" -ne 1 ]
    echo "Usage $0 "
    exit 1

grep -nr -C 2 -- "$1" /Applications/