The roots of an obscure Bourne shell error message

Suppose that you’re writing Bourne shell code that involves using some commands in a subshell to capture some information into a shell variable, ‘AVAR=$(….)’, but you accidentally write it with a space after the ‘=’. Then you will get something like this:

$ AVAR= $(... | wc -l)
sh: 107: command not found

So, why is this an error at all, and why do we get this weird and obscure error message? In the traditional Unix and Bourne shell way, this arises from a series of decisions that were each sensible in isolation.

I love these kinds of investigations.

3 Comments

  1. 2023-09-13 3:11 pm
  2. 2023-09-14 2:43 am
  3. 2023-09-14 10:40 am