Undocumented options

Rich Trouton posted today about undocumented options for the asr command-line utility.

On Twitter, Marnin asked:

Lots of OS X utilities have undocumented options. Take for example /usr/sbin/softwareupdate — the command-line Apple Software Update utility.

It’s had several undocumented options for years. Two useful ones:

  1. --CatalogURL lets you specify an alternate URL for a software update catalog. This can be used to point to an internal software update server:

    softwareupdate -l --CatalogURL http://yoursoftwareupdateserver/index.sucatalog

  2. -f filename causes softwareupdate to write some interesting metadata to filename. What’s not immediately apparent is that this file gets (re)written several times while softwareupdate runs. You could monitor this file to provide some sort of status update while softwareupdate runs. The metadata that is written to this file might be useful if you were writing some code that handled Apple Software Update for you…

I noticed today that Mountain Lion’s version of softwareupdate adds a few more undocumented options, though I’m not entirely sure what they do exactly. The new options are --force-scan, --printurls, --background, and --background-critical:

% sudo softwareupdate --force-scan -l
Software Update Tool
Copyright 2002-2010 Apple

No new software available.

% sudo softwareupdate --printurls -l
Software Update Tool
Copyright 2002-2010 Apple

No new software available.

% sudo softwareupdate --background -l
softwareupdate[44238]: Triggering background check with normal scan ...

% sudo softwareupdate --background-critical -l
softwareupdate[44254]: Triggering background check with normal scan (critical updates only) ...

I’m sure that the first two might be more interesting if I actually had some available updates.

You might be wondering how one discovers undocumented options. One way is to use the strings command against a binary:

strings /usr/sbin/softwareupdate

I then look at the strings in the vicinity of known, documented options. Here’s a snippet of the output of the above command:

list
download
install
recommended
ignore
reset-ignored
schedule
lang
verbose
background
background-critical
force-scan
printurls
contentLocator
help
testhelp

Compare that to softwareupdate‘s help message:

sudo softwareupdate --help
usage: softwareupdate [ ...]

-l | --list List all appropriate updates
-d | --download Download Only
-i | --install Install
... specific updates
-a | --all all appropriate updates
-r | --recommended only recommended updates

--ignore ... Ignore specific updates
--reset-ignored Clear all ignored updates
--schedule (on | off) Set automatic checking

-v | --verbose Enable verbose output
-h | --help Print this help

If you take a look at the output of strings /usr/sbin/softwareupdate, you may find some other interesting undocumented bits. Have fun!

Undocumented options

One thought on “Undocumented options

  1. […] The result of this interest has lead to some methods for finding hidden options in any command, although his specific example involved softwareupdate.  These methods are useful for poking around commands and looking for hidden functionality that isn’t exposed in the documentation.  Check it out over on Greg’s blog. […]

Comments are closed.