iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Quiz

Eight quick questions on bash fundamentals, quoting, and strict mode.

Sample questions

EXAMPLE
# Bash quiz

1) Strict mode pragma is usually:
   a) set -e
   b) set -Eeuo pipefail
   c) set -x
   d) set -t

2) IFS controls:
   a) syntax highlighting
   b) field splitting in word expansion
   c) shell aliases
   d) pipe behaviour

3) Difference between single and double quotes:
   a) double quotes expand $variables, single quotes do not
   b) only single quotes survive in subshells
   c) double quotes disable globbing
   d) there is none

4) Process substitution \<( cmd ):
   a) writes cmd output to a temp file passed as a path
   b) renders ANSI codes
   c) prepends sudo
   d) is a heredoc shortcut

5) Which array form preserves spaces in arguments?
   a) \$args
   b) \${args[*]}
   c) \"\${args[@]}\" - quoted, with @
   d) args.join(\' \')

6) Best way to check a command exists portably:
   a) which cmd
   b) command -v cmd
   c) hash cmd
   d) [ -x cmd ]

7) The biggest gotcha with read inside a pipe:
   a) it cannot read text
   b) the loop runs in a subshell so changes to variables are lost
   c) it always returns 1
   d) it requires sudo

8) ShellCheck is:
   a) a remote service
   b) a static analyser - run it in CI on every shell file
   c) part of bash itself
   d) deprecated

Answers: 1b, 2b, 3a, 4a, 5c, 6b, 7b, 8b.

Why it matters

Quoting and IFS catch most bash mistakes. Strict mode + ShellCheck remove the rest. If you nail these eight, your scripts are ready for production cron.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
# 3 questions per lesson.
Try it Yourself »

Discussion

Loading…