Story Details

  • The history and use of /etc./glob in early Unixes

    Posted: 2025-01-13 05:44:29

    Chris Siebenmann's blog post, "The history and use of /etc/glob in early Unixes," delves into the historical context and functionality of the /etc/glob file, a mechanism for global command aliases present in Version 6 Unix and its predecessors. Siebenmann begins by highlighting the limited disk space and memory constraints of these early Unix systems, which necessitated creative solutions for managing common commands and reducing redundancy. /etc/glob addressed this by providing a centralized repository for text substitutions that would be applied system-wide.

    The post meticulously explains the operation of /etc/glob. Essentially, /etc/glob contained a list of pairs of strings. Whenever a command was entered, the shell would consult this file. If the first string of any pair matched the beginning of the command, the matching portion of the command would be replaced with the second string of that pair. This allowed for abbreviation of frequently used commands, parameterization of commands with common arguments, and even the creation of entirely new commands built upon existing ones.

    Siebenmann provides concrete examples gleaned from historical Unix sources, illustrating the practical application of /etc/glob. One example demonstrates how ls -l could be abbreviated to simply ll, significantly reducing typing effort. Another shows how commands could be pre-configured with specific options, such as always listing directories in long format. The post also emphasizes the powerful, albeit potentially confusing, ability to chain multiple substitutions together, allowing complex transformations of commands based on the defined patterns.

    The post further discusses the historical evolution of /etc/glob. While initially existing as a standalone file, its functionality was eventually incorporated directly into the shell itself in later Unix versions. This integration streamlined the command parsing process and obviated the need for a separate file. The reasons for this transition likely stemmed from efficiency improvements and a desire for a more unified command interpretation approach.

    Finally, Siebenmann draws a parallel between /etc/glob and modern features like shell aliases and functions. While functionally similar in their ability to create shortcuts and customized commands, /etc/glob differed in its global scope and its application prior to argument parsing. This distinction underlines the evolution of command processing in Unix systems, moving from a centralized, pre-parsing substitution mechanism to the more localized and flexible approaches prevalent today. The post concludes by noting the enduring influence of /etc/glob on contemporary features, serving as a historical precursor to the powerful command manipulation capabilities we take for granted in modern shells.

    Summary of Comments ( 23 )
    https://news.ycombinator.com/item?id=42680437

    The Hacker News post titled "The history and use of /etc./glob in early Unixes" has generated a moderate discussion with several interesting comments. The comments primarily focus on historical context, technical details related to globbing, and personal anecdotes about using or encountering this somewhat obscure Unix feature.

    One commenter provides further historical context by mentioning that Version 6 Unix's shell did not support globbing, meaning the expansion of wildcard characters like * and ?, directly. Instead, /etc/glob was used as an external program to perform this expansion. This detail highlights the evolution of the shell and its built-in capabilities over time.

    Another commenter elaborates on the mechanics of how /etc/glob interacted with the shell. They explain that the shell would identify commands starting with an unescaped wildcard, then execute /etc/glob to expand the wildcards. The expanded argument list was then passed to the actual command being executed. This clarifies the role of /etc/glob as an intermediary for handling wildcards in older Unix systems.

    A subsequent comment thread discusses the use of set -f (or noglob) in modern shells to disable wildcard expansion. This connection is made to illustrate that while globbing is now integrated into the shell itself, mechanisms to disable it still exist, echoing the older behavior where globbing wasn't a default shell feature.

    Someone shares a personal anecdote about encountering remnants of /etc/glob in a much later version of Unix (4.3BSD). Although no longer functional, the presence of the /etc/glob file serves as a historical artifact, reminding users of earlier Unix implementations.

    Another comment explains the security implications of directly executing the output of programs in the shell. They highlight that directly substituting the output of /etc/glob into the command line could lead to command injection vulnerabilities if filenames contained special characters. This observation points to the potential risks associated with early implementations of globbing.

    A commenter also mentions the influence of Multics on early Unix, suggesting that some of these design choices might have been inherited or influenced by Multics' features. This provides a broader context by linking the development of Unix to its predecessors.

    Finally, a few comments touch upon alternative globbing mechanisms like the use of backticks, further enriching the discussion by presenting different approaches to handling filename expansion in older shells.

    Overall, the comments on the Hacker News post provide valuable insights into the historical context, technical details, and practical implications of /etc/glob in early Unix systems. They offer a glimpse into the evolution of the shell and its features, as well as the challenges and considerations faced by early Unix developers.