Skip to main content
added 10 characters in body
Source Link
Mingye Wang
  • 1.2k
  • 10
  • 23

None of the keywords are treated like commands. But sure, you can have commands/functions with the same name, e.g.:

None of the keywords are treated like commands. But sure, you can have commands with the same name, e.g.:

None of the keywords are treated like commands. But sure, you can have commands/functions with the same name, e.g.:

added 122 characters in body
Source Link
Mingye Wang
  • 1.2k
  • 10
  • 23

If you have heard about Yacc or BisonBison (or well, jison), that's how people might use the grammar. With these parsers generators, they can generate something that figures out what parts of the grammar a given flow of input 'tokens' are spoken in.

None of the keywords are treated like commands. But sure, you can have commands with the same name, e.g.:

# make a command to avoid command-not-found for `FOO=BAR time cmd`
time(){ time "$@"; }

If you have heard about Yacc or Bison (or well, jison), that's how people might use the grammar. With these parsers generators, they can generate something that figures out what parts of the grammar a given flow of input 'tokens' are spoken in.

None of the keywords are treated like commands. But sure, you can have commands with the same name.

If you have heard about Yacc or Bison (or well, jison), that's how people might use the grammar. With these parsers generators, they can generate something that figures out what parts of the grammar a given flow of input 'tokens' are spoken in.

None of the keywords are treated like commands. But sure, you can have commands with the same name, e.g.:

# make a command to avoid command-not-found for `FOO=BAR time cmd`
time(){ time "$@"; }
added 122 characters in body
Source Link
Mingye Wang
  • 1.2k
  • 10
  • 23

Q1, Q2

%token  If    Then    Else    Elif    Fi    Do    Done
/*      'if'  'then'  'else'  'elif'  'fi'  'do'  'done'   */


%token  Case    Esac    While    Until    For
/*      'case'  'esac'  'while'  'until'  'for'   */

/* and 'In' too -- They made a mistake! */
%token  In
     /*      'in'   */

Q3

Q4

Also think about [[. If [[ have not been a keyword, constructs like [[ ($a == 2) || ($b != 3) ]] will make the shell find stray parentheses and complain. (Replace [[ with [ and see).

P.S. time is a utility instead of a keyword in POSIX, although the latter is still considered acceptable. The whole time-a-trunk-of-commands thing is a ksh and bash extension.

%token  If    Then    Else    Elif    Fi    Do    Done
/*      'if'  'then'  'else'  'elif'  'fi'  'do'  'done'   */


%token  Case    Esac    While    Until    For
/*      'case'  'esac'  'while'  'until'  'for'   */

/* and 'In' too -- They made a mistake! */
%token  In
 /*      'in'   */

Also think about [[. If [[ have not been a keyword, constructs like [[ ($a == 2) || ($b != 3) ]] will make the shell find stray parentheses and complain. (Replace [[ with [ and see).

Q1, Q2

%token  If    Then    Else    Elif    Fi    Do    Done
/*      'if'  'then'  'else'  'elif'  'fi'  'do'  'done'   */


%token  Case    Esac    While    Until    For
/*      'case'  'esac'  'while'  'until'  'for'   */

/* and 'In' too -- They made a mistake! */
%token  In    /*      'in'   */

Q3

Q4

Also think about [[. If [[ have not been a keyword, constructs like [[ ($a == 2) || ($b != 3) ]] will make the shell find stray parentheses and complain. (Replace [[ with [ and see).

P.S. time is a utility instead of a keyword in POSIX, although the latter is still considered acceptable. The whole time-a-trunk-of-commands thing is a ksh and bash extension.

Source Link
Mingye Wang
  • 1.2k
  • 10
  • 23
Loading