Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

  • Print
  • + Share This
Like this article? We recommend

No Introspection

The UNIX command line is considered one of its greatest assets. While I like the concept of a command line in principle, I consider the UNIX shell to be one of the worst possible implementations of the ideal.

Anyone who has used zsh will be familiar with the incredible auto-completion features it provides. For a great many programs, it can auto-complete command-line options. When you use the secure copy program, it can even create a remote shell on the other machine and auto-complete filenames for you. Looking at how this works, however, is likely to give anyone nightmares. For each program (or group of programs, if you're really lucky), a parser is built that scans the help output from that program and creates the auto-completion list. When you add a new program that doesn't produce a help screen, or produces one in a different format, zsh is stuck.

Consider now a hypothetical system in which each object, including programs, supported simple introspection methods. In this system, the shell could query the applications with a well-defined interface to get a list of available options. It could also get restrictions on the types of input files and other useful data. In an ideal system, this information would be locale-specific, so the user could enter command-line options in his or her own language.

Introspection is useful in a large number of cases. On Mac OS, the underlying file system supports the most basic form of introspection on files—you can get a 32-bit file type. This isn't ideal, but it at least allows some kind of intelligent decision to be made about which application should be used to open the file. Taking this capability a step further, each file type could have a machine-parsable description of the file structure associated with it. A word processing program could then scan a file from another system and translate it easily into its native format using this information—at the very least, it could extract the plain text and maybe some basic formatting.

  • + Share This
  • 🔖 Save To Your Account