dominictarr/JSON.sh — pull request #2 by nicholasrobinson (2011-10-25 22:00:25+00:00)
Title: Updated wrapper for FreeBSD/OS X compatibility

On OSX the bin/json_parse wrapper would error on the 'readlink -f' command, giving the following output:

$ curl registry.npmjs.org/express | ./json_parse
readlink: illegal option -- f
usage: readlink [-n] [file ...]
usage: dirname path
./json_parse: line 5: /../parse.sh: No such file or directory
./json_parse: line 6: tokenize: command not found
./json_parse: line 6: parse: command not found
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
33 56635 33 18824 0 0 57431 0 --:--:-- --:--:-- --:--:-- 74110
curl: (23) Failed writing body (0 != 2896)

This can be overcome whilst maintaining linux compatibility with substitution of
__filename=$(cd "$(dirname "$0")"; pwd)
. $__filename/../parse.sh

in place of

__filename=`readlink -f $0`
. `dirname $__filename`/../parse.sh