colis-anr / morbig

A static parser for POSIX Shell
Other
190 stars 8 forks source link

Two reserved keywords in a row should be considered both "well separated"? #105

Open Niols opened 5 years ago

Niols commented 5 years ago

Let us have a look at:

{ for foo in a b c; do
      bar
  done }

refused by Morbig because of the } after done but accepted by Dash and Bash. I wonder if being "well separated" works when the previous word is already a reserved word. After all, we never separate after a reserved word, it's only important before.

Niols commented 4 years ago

@yurug Do you think this is a bug in Morbig? Or a different interpretation of the standard?

Niols commented 4 years ago

Actually, in 2.4 Reserved Words, it is said:

Reserved words are words that have special meaning to the shell; see Shell Commands. The following words shall be recognized as reserved words:

!             do            esac          in
{             done          fi            then
}             elif          for           until
case          else          if            while

This recognition shall only occur when none of the characters is quoted and when the word is used as:

  • The first word of a command
  • The first word following one of the reserved words other than case, for, or in
  • […]
Niols commented 4 years ago

So this should, in my opinion, be a bug in Morbig and has actually nothing to do with "well separated" keywords (for which I can't find a reference anymore).