Archive for February, 2009

Command Order of Precedence

The common misconception is that the shell always searches the PATH variable to find a command. The truth is that the shell may never get to the PATH variable before it has a name match. Before confusing the issue, let’s look at a simple example. If there is an alias that reads which=’whence -a’, and you enter which pwd, the which command is never executed. The shell first finds the alias, and then subsitutes the alias for the command, and starts the search all over. From this, we know that an alias has precedence over the PATH variable. So what is the order of precedence for finding the command?

» Continue reading “Command Order of Precedence”

Share

Comments (2)

The man Command Lies (Sometimes)

There are man pages with typographical errors, but that is not the issue of this post. Assuming you are using ksh or bash, how do you answer these questions:

  1. Is the man page for awk correct?
  2. Is the man page for pwd correct?

If you answered yes to both questions, you are wrong, but for different reasons. » Continue reading “The man Command Lies (Sometimes)”

Share

Leave a Comment

Trapped in Bourne Shell

Bash and KornShell offer features that are more powerful, and often, more efficient than Bourne Shell. Yet, I constantly see back tics (accent graves), instead of the easier to read format of $(…). I see the use of the expr command for math calculations in stead of (( … )). Even higher on the list of common sins is the use of [ ... ], instead of [[ ... ]]. It is my contention that the blame lies on introductory books and courses, which change the title to Bash Shell Programming, or KornShell Programming, but are nothing more than warmed-over Bourne Shell courses. So whey not use Bourne Shell syntax? After all, isn’t Bourne Shell the standard UNIX shell?

» Continue reading “Trapped in Bourne Shell”

Share

Comments (1)