Is that an alias or a command?

When executing shell commands, I occassionally find that my alias definitions collide with actual commands. This periodically causes unexpected side effects, and munges the command output when additional options and pipelines are present. Since I use the Korn shell as my primary shell, I frequently use the whence(1) shell built-in to resolve these issues:

$ whence -v ls
ls is a tracked alias for /bin/ls

$ whence -v awk
awk is /bin/awk

whence(1) will provide a summary of the command passed as an argument, which can be helpful for determining if the command is an alias, function or an actual command. If you want to view all aliases, you can use the alias(1m) command without any options:

$ alias
autoload=’typeset -fu’
cat=/bin/cat
command=’command ‘
functions=’typeset -f’
history=’fc -l’
integer=’typeset -i’
local=typeset
ls=/bin/ls
nohup=’nohup ‘
r=’fc -e -‘
stop=’kill -STOP’
suspend=’kill -STOP $$’

UNIX shells contain lots of obscure commands and functionality, and are one of the coolest things to learn about!!

Why Apple and OS X rock

One of my friends e-mailed me the following link today, and it brought back memories (horror stories actually — since most of my problems involved hours and hours with gdb and core files) from the days when I used Linux as my main desktop at home. I eventually got sick of the constant hassle required to make my Linux desktop usable, and purchased a Mac to ease my computing life at Casa de Matty. Now don’t get me wrong — I love debugging technical problems, but I hate spending my spare time fighting with with an OS (and window manager) to view photos, listen to music, and to securely access remote resources. Apple has done some amazing stuff, and I look forward to seeing cool products and more innovation come out of Cuppertino!

Viewing shared library search order

When debugging library search path problems, it is often useful to see which libraries are used, and the order in which they are accessed. This is easily accomplished with the Solaris ldd(1m) utilities “-s” option:

$ ldd -ss /usr/sfw/bin/wget |more

   find object=libsocket.so.1; required by /usr/sfw/bin/wget
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libsocket.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libsocket.so.1
        libsocket.so.1 =>        /usr/lib/libsocket.so.1

   find object=libnsl.so.1; required by /usr/sfw/bin/wget
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libnsl.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libnsl.so.1
        libnsl.so.1 =>   /usr/lib/libnsl.so.1

   find object=libc.so.1; required by /usr/sfw/bin/wget
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libc.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libc.so.1
        libc.so.1 =>     /usr/lib/libc.so.1

   find object=libnsl.so.1; required by /usr/lib/libsocket.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libnsl.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libnsl.so.1

   find object=libc.so.1; required by /usr/lib/libsocket.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libc.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libc.so.1

   find object=libdl.so.1; required by /usr/lib/libnsl.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libdl.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libdl.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1

   find object=libc.so.1; required by /usr/lib/libnsl.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libc.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libc.so.1

   find object=libmp.so.2; required by /usr/lib/libnsl.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libmp.so.2
    search path=/usr/lib  (default)
    trying path=/usr/lib/libmp.so.2
        libmp.so.2 =>    /usr/lib/libmp.so.2

   find object=libdl.so.1; required by /usr/lib/libc.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libdl.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libdl.so.1

   find object=libc.so.1; required by /usr/lib/libmp.so.2
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libc.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libc.so.1

   object=/usr/lib/libc.so.1; filter for /usr/platform/$PLATFORM/lib/libc_psr.so.1

   find object=/usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1; required by /usr/lib/libc.so.1
        /usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1

   object=/usr/lib/libdl.so.1; filter for /usr/lib/ld.so.1

I find this useful for finding references to outdated libraries, and libraries that are not located in standard locations (e.g., /usr/lib).