No equivalent to strace on OS X and the mysterious left square bracket

Tonight a friend pointed out that there is a weird file in /bin on OS X. If you do ‘ls -la /bin’ you will most probably see a file called [. That is not a typo, the file has the left square bracket as a name.

Curious off the bat about what it does, I fired up strace and ran the [ file. Except strace doesn’t exist on OS X. strace lets you trace system calls and signals on a running file or a file that you run. Basically strace lets you watch what a file is doing. This can be very useful to solve mysterious problems.

So if you are on OS X and you need strace, you can always use ktrace instead. It works mostly the same it seems.

As for the /bin/[ file, it didn’t seem to do anything when I ran ‘ktrace /bin/[’

If I use otool to see what [ depends on it gives me:
[php][root scripts] otool -L /bin/[
/bin/[:
      /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.5)
[/php]

running strings - /bin/[ gives me long list:
[php][root scripts] strings - /bin/[
__PAGEZERO
__TEXT
__text
__TEXT
__cstring
__TEXT
__textcoal_nt
__TEXT
__DATA
__data
__DATA
__dyld
__DATA
__const
__DATA
__common
__DATA
__IMPORT
__pointers
__IMPORT
__jump_table
__IMPORT
__LINKEDIT
/usr/lib/dyld
/usr/lib/libgcc_s.1.dylib
/usr/lib/libSystem.B.dylib
,[^_]
[^_]
[^_]
,[^_]
,[^_]
?8!u
?8!uu?x
|[^_]
__dyld_make_delayed_module_initializer_calls
__dyld_mod_term_funcs
%s: %s
%s: out of range
%s: bad number
argument expected
closing paren expected
missing ]
unknown operand
_NXArgc
_NXArgv
___progname
__mh_execute_header
_catch_exception_raise
_catch_exception_raise_state
_catch_exception_raise_state_identity
_clock_alarm_reply
_do_mach_notify_dead_name
_do_mach_notify_no_senders
_do_mach_notify_port_deleted
_do_mach_notify_send_once
_do_seqnos_mach_notify_dead_name
_do_seqnos_mach_notify_no_senders
_do_seqnos_mach_notify_port_deleted
_do_seqnos_mach_notify_send_once
_environ
_receive_samples
__DefaultRuneLocale
___error
___keymgr_dwarf2_register_sections
___maskrune
__cthread_init_routine
_abort
_access
_atexit
_errno
_errx
_exit
_getegid
_geteuid
_isatty
_lstat
_mach_init_routine
_stat
_strcmp
_strtol
8__PAGEZERO
__TEXT
__text
__TEXT
__symbol_stub
__TEXT
__picsymbol_stub__TEXT
$__symbol_stub1
__TEXT
__cstring
__TEXT
__picsymbolstub1__TEXT
__DATA
__data
__DATA
__nl_symbol_ptr
__DATA
__la_symbol_ptr
__DATA
__dyld
__DATA
__const
__DATA
__common
__DATA
8__LINKEDIT

/usr/lib/dyld
/usr/lib/libgcc_s.1.dylib
/usr/lib/libSystem.B.dylib
#x|y
}“Kx@
9),?H
}“Kx
<8c,
@8c,
88c,
H8c,
L8c,
P8c-
- 9k-4
D8c-HH
x?B0
k0d}i
3x8`
X|BJ
__dyld_make_delayed_module_initializer_calls
__dyld_image_count
__dyld_get_image_name
__dyld_get_image_header
__dyld_NSLookupSymbolInImage
__dyld_NSAddressOfSymbol
libobjc
__objcInit
__dyld_mod_term_funcs
%s: %s
%s: out of range
%s: bad number
argument expected
closing paren expected
missing ]
unknown operand
_NXArgc
_NXArgv
___progname
__mh_execute_header
_catch_exception_raise
_catch_exception_raise_state
_catch_exception_raise_state_identity
_clock_alarm_reply
_do_mach_notify_dead_name
_do_mach_notify_no_senders
_do_mach_notify_port_deleted
_do_mach_notify_send_once
_do_seqnos_mach_notify_dead_name
_do_seqnos_mach_notify_no_senders
_do_seqnos_mach_notify_port_deleted
_do_seqnos_mach_notify_send_once
_environ
_receive_samples
__DefaultRuneLocale
___error
___keymgr_dwarf2_register_sections
___maskrune
__cthread_init_routine
_abort
_access
_atexit
_errno
_errx$LDBL128
_exit
_getegid
_geteuid
_isatty
_lstat
_mach_init_routine
_stat
_strcmp
_strtol
[/php]

So, I have no more time to investigate further right now, and Google shows nothing useful. If anyone has an idea of what the mysterious [ binary does, please let me know. Thanks!