[{"id":"bashbeginner-001","courseId":"bash-beginner","domain":"syntax-and-commands","topic":"Simple commands","prompt":"A teammate types `cp notes.txt backup/` at the prompt. Which part of that line is the command, and which are its arguments?","hint":"Look at which word the shell reads first, and what the rest of the line is for.","explain":"A line at the prompt is split into words at blanks, and the line ends at a control operator such as ; or |. The role each word plays depends on its position in the line.","source":"https://www.gnu.org/software/bash/manual/html_node/Simple-Commands.html","interaction":{"type":"single"},"options":[{"id":"a","text":"cp is the command; notes.txt and backup/ are its arguments","why":"The first word names the command to run, and every later word is passed to it as an argument."},{"id":"b","text":"cp notes.txt is the command; backup/ is its argument","whyNot":"The command is only the first word; the words after it are arguments, not part of the name."},{"id":"c","text":"cp is the command; backup/ is its only argument","whyNot":"Every word after the first is an argument, so notes.txt counts as one too."},{"id":"d","text":"All three words together form one command name","whyNot":"Blanks separate words, and the shell does not join them into a single name."}],"answer":"a","explanation":"A simple command is a sequence of words separated by blanks, ending at a control operator; the first word names the command and the rest are its arguments.","concept":"A simple command is a sequence of words separated by blanks, ending at a control operator; the first word names the command and the rest are its arguments.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["In a simple command, the first word is the command and every later word is an argument."]},{"id":"bashbeginner-002","courseId":"bash-beginner","domain":"syntax-and-commands","topic":"Exit status of a command","prompt":"A script runs a command named pritnf, a typo for printf that does not exist on the system. What exit status does Bash give that failed command?","hint":"Think about a name that cannot be found, as opposed to a program that is found but cannot run.","explain":"An exit status is a number from 0 to 255 that a finished command reports. Zero means success and any other value means failure, and the number can show what kind of failure it was.","source":"https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html","interaction":{"type":"single"},"options":[{"id":"a","text":"127","why":"When a command is not found, the child process created to run it returns status 127."},{"id":"b","text":"0","whyNot":"Zero means success, and a command that could not be found has not succeeded."},{"id":"c","text":"126","whyNot":"126 is for a command that is found but not executable, which is a different failure."},{"id":"d","text":"2","whyNot":"2 is for builtins given incorrect usage, such as invalid options or missing arguments."}],"answer":"a","explanation":"A command that is not found returns exit status 127, a command found but not executable returns 126, and zero means success.","concept":"A command that is not found returns exit status 127, a command found but not executable returns 126, and zero means success.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Exit status 127 means the command was not found; 126 means it was found but could not be run."]},{"id":"bashbeginner-003","courseId":"bash-beginner","domain":"syntax-and-commands","topic":"Command lists with && and ||","prompt":"In the list `make && make install`, the command `make install` still runs when `make` exits with a non-zero status.","hint":"Think about what the && operator checks on the command before it.","explain":"A list joins commands with operators, and each operator looks at the exit status of the command on its left. Only then does it decide whether the command on its right gets to run.","source":"https://www.gnu.org/software/bash/manual/html_node/Lists.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"With &&, the right command runs only if the left one returns zero, so a failed make skips make install."},{"id":"b","text":"False","why":"The && operator runs its right side only when the left side succeeds; a non-zero status from make stops make install."}],"answer":"b","explanation":"In an AND list, command2 runs if and only if command1 returns zero; in an OR list, command2 runs only if command1 returns a non-zero status.","concept":"In an AND list, command2 runs if and only if command1 returns zero; in an OR list, command2 runs only if command1 returns a non-zero status.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["With &&, the right command runs only after the left one succeeds; with ||, only after it fails."]},{"id":"bashbeginner-004","courseId":"bash-beginner","domain":"syntax-and-commands","topic":"Pipelines","prompt":"A script runs several commands joined by the pipe operator. Which TWO statements about the exit status of that pipeline are correct in Bash?","hint":"Ask which command's status the pipeline reports, and whether the pipefail option changes that.","explain":"A pipeline connects each command's output to the next command's input, and the shell waits for them all. It reports one exit status, and a shell option can change which command's status that is.","source":"https://www.gnu.org/software/bash/manual/html_node/Pipelines.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"By default, the pipeline's exit status is the exit status of its last command.","why":"Without pipefail, only the final command's status is reported for the whole pipeline."},{"id":"b","text":"With pipefail enabled, the status is that of the rightmost command that exits non-zero, or zero if all succeed.","why":"pipefail makes a failure in any stage count, and the rightmost non-zero status is the one reported."},{"id":"c","text":"By default, the pipeline's exit status is the exit status of its first command.","whyNot":"The first command's status is not used by default; the last command's status is."},{"id":"d","text":"By default, a failure in any command makes the whole pipeline report failure.","whyNot":"Without pipefail, an early failure is ignored when the last command succeeds."},{"id":"e","text":"With pipefail enabled, the status is that of the leftmost command that exits non-zero.","whyNot":"pipefail looks at the rightmost failing command, not the leftmost one."},{"id":"f","text":"A pipeline ending in & returns the exit status of its last command.","whyNot":"An asynchronous pipeline returns 0 right away and does not wait for its commands."}],"answer":"ab","explanation":"A pipeline's exit status is that of its last command, unless pipefail is set; then it is the rightmost command to exit non-zero, or zero if all succeed.","concept":"A pipeline's exit status is that of its last command, unless pipefail is set; then it is the rightmost command to exit non-zero, or zero if all succeed.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Without pipefail, a failing command early in a pipeline goes unnoticed if the last command succeeds."]},{"id":"bashbeginner-005","courseId":"bash-beginner","domain":"syntax-and-commands","topic":"if statements","prompt":"An if command has an elif clause and no else. Its test and the elif test both fail, so no branch runs. What exit status does the whole if command return?","hint":"Think about what the if command reports when none of its tests succeeded.","explain":"An if command runs a branch only when its test returns zero, trying each elif in turn. Its own status comes from the last command it ran, so consider the case where no branch runs.","source":"https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html","interaction":{"type":"single"},"options":[{"id":"a","text":"Zero, because no condition tested true","why":"When no condition tests true and no branch runs, the if command's return status is zero."},{"id":"b","text":"The non-zero status of the last elif test","whyNot":"That test ran last, but when no condition tested true, the if command reports zero."},{"id":"c","text":"One, because a failed test counts as an error","whyNot":"A failed test is a normal result that just skips the branch; it is not an error for the if command."},{"id":"d","text":"Non-zero, because the whole if command failed","whyNot":"A failed test only skips a branch; the if command does not fail because of it."}],"answer":"a","explanation":"The return status of an if command is the exit status of the last command executed, or zero if no condition tested true.","concept":"The return status of an if command is the exit status of the last command executed, or zero if no condition tested true.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["An if command that runs no branch returns zero, so a failing test alone does not make the if fail."]}]