It seems a command line like texdoc -iw is not understood as texdoc -i -w, like nearly every other program in existence. Does Lua really not have a standard getopt available? Sigh. Also, the error message has a typo: texdoc error: unknow option: -iw That should be "unknown".