Bash syllabus planning

Bash is a top-10 language at Exercism (by number of students). It’s time to add a syllabus to it.

My suggestion is to not re-invent the wheel: use the BashGuide as the main source of content (attributed of course)

A proposed curriculum: I’d appreciate feedback.


  1. Basic syntax: commands and arguments

    • a cautionary note: this syllabus will be about programming in bash, not about using it as an interactive shell.
    • separated by whitespace
    • commands can be external, builtin, keywords, functions, aliases
    • arguments can contain whitespace if quoted
    • a cautionary note: [ is a builtin command, so needs space before its arguments
      • “We will see much more about [ in later lessons.”
    • scripts, shebang, no aliases
    • positional parameters
  2. variables and expansions

    • variable assignment
      • no spaces around =
    • command substitution to capture command output
    • parameter expansions
      • don’t need to go into exhausive list, but the essentials
      • default value ${var:-default}
      • pattern replacement ${var//pattern/replacement}
      • “trimming” ${var%.*} ${var##*/}
    • $@ and $*
  3. word splitting and filename expansion

    • to discuss the importance of quoting
    • basic shell patterns: *, ?
    • brace expansions and how it’s different from patterns /path/to/{foo,bar,baz}.txt
    • set -f
  4. conditionals

    • truthiness
    • [ versus test versus [[
    • if COND_COMMANDS; then COMMANDS; elif COND_COMMANDS; then COMMANDS; else COMMANDS; fi
      • how COND_COMMANDS doesn’t need [ at all
    • case
  5. loops

    • while, until
    • for elem in elements …
    • arithmetic for
  6. conditionals 2

    • boolean operators && ||
    • how A && B || C != if A; then B; else C; fi
  7. arrays

    • numeric and associative
    • iteration
    • namerefs
  8. functions

  9. pipelines and subshells

x. I/O

  • file descriptors, stdin, stdout, stderr
  • redirection
  • here-docs and here-strings
  • exec and redirections
  • command substitution
    • capturing stdout and stderr
    • capturing stdout and stderr into separate variables

x. arithmetic

x. variables 2

  • scope
  • attributes: -i -l -u

x. option parsing with getopts

x. set command and “strict mode”

  • pros and cons of
    • set -e
    • set -u
  • $- variable
  • -opt versus +opt
  • debugging with -x and -v
5 Likes

This looks awesome and I think it would be very high value!

I think this is the best way to go. Would we copy/paste chunks (may require manual syncing) or link to Wooledge (relies on external resources)?

[..] is also essential here IMO.

I would introduce (( at the same time as [[.

That’s a whole painful can of worms :smile:

I would copy/edit to put my spin on the wording. I find that site can get a touch snarky.

1 Like

Yep, open it! I’d write about shellcheck in there as well.

Dammit, I knew I was missing one.

Hmm, we’ll discuss it. IMO arithmetic is a separate concept.

1 Like

Sounds great! This will be really helpful. I also think that adapting the linked material is the best option. You want to tweak things to best fit exercism.

I am activelly trying to learn more about bash and would 100% join the course as soon as it comes out.

Very happy and excited to see that the bash learning pth might become a reallity! Thank you all :)

1 Like