<aside> 💡

Color codes:

Mandatory pipeline

Mandatory.png

Bonus pipeline

Bonus.png

➤ 3 main differences:

  1. expand_all_tokens is replaced by defer_expand_tokens for conditional expansion
  2. expand_wildcards is added before parsing
  3. The parser’s entry point calls parse_and_or first instead of parse_pipeline

Stage by stage breakdown

1. Tokenizer tokenizer_utils_bonus.c

The bonus adds 4 operators:

Token Characters Purpose
TOKEN_AND && Logical AND
TOKEN_OR `
TOKEN_LPAREN ( Open subshell
TOKEN_RPAREN ) Close subshell

is_operator(char c)

get_operator_token_type(char *str, int *len)

2. Deferred expansion expander_bonus.c

In mandatory all variables are expanded before parsing, but in bonus variables after && and || are deferred to execution.