mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore(curriculum): audit bash scripting quiz (#60462)
This commit is contained in:
+23
-23
@@ -61,45 +61,45 @@ Which command would define `MY_VAR` and print it to the console?
|
||||
|
||||
#### --text--
|
||||
|
||||
How do you declare a numeric variable?
|
||||
Which command is used to view all variables in the shell?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`declare -n MY_VAR=1`
|
||||
`declare -n env`
|
||||
|
||||
---
|
||||
|
||||
`declare -d MY_VAR=1`
|
||||
`declare -p env`
|
||||
|
||||
---
|
||||
|
||||
`declare -x MY_VAR=1`
|
||||
`declare -x bashrc`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`declare -i MY_VAR=1`
|
||||
`declare -p`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Which command would not run a `script.sh` file?
|
||||
Which command would run a `script.sh` file?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`./script.sh`
|
||||
`script.sh bash`
|
||||
|
||||
---
|
||||
|
||||
`/tmp/script.sh`
|
||||
`zsh ./script.sh`
|
||||
|
||||
---
|
||||
|
||||
`bash script.sh`
|
||||
`./sh script.sh`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`script.sh`
|
||||
`./script.sh`
|
||||
|
||||
### --question--
|
||||
|
||||
@@ -127,7 +127,7 @@ How to view the manual for the `less` command in bash?
|
||||
|
||||
#### --text--
|
||||
|
||||
How would you call `print_arguments` to print `a` and `b` to the terminal?
|
||||
How would you call the `print_arguments` function to print `a` and `b` to the terminal?
|
||||
|
||||
```bash
|
||||
print_arguments() {
|
||||
@@ -348,7 +348,7 @@ How would you assign the result of the sum of variables `A` and `B` to the varia
|
||||
|
||||
---
|
||||
|
||||
`C=$(( A + B ))`
|
||||
`C=$( A + B )`
|
||||
|
||||
---
|
||||
|
||||
@@ -356,29 +356,29 @@ How would you assign the result of the sum of variables `A` and `B` to the varia
|
||||
|
||||
#### --answer--
|
||||
|
||||
`C=$(( $A + $B ))`
|
||||
`C=$(( A + B ))`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
What keyword in a loop skips the rest of the current iteration and begins the next iteration?
|
||||
Which command is used to create a new file?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`break`
|
||||
`newfile`
|
||||
|
||||
---
|
||||
|
||||
`until`
|
||||
`echo new_file`
|
||||
|
||||
---
|
||||
|
||||
`done`
|
||||
`fileargs`
|
||||
|
||||
#### --answer--
|
||||
|
||||
`continue`
|
||||
`touch`
|
||||
|
||||
### --question--
|
||||
|
||||
@@ -406,23 +406,23 @@ Prints the exit code of the last executed command.
|
||||
|
||||
#### --text--
|
||||
|
||||
What value of `MY_VAR` would satisfy the condition `[[ $MY_VAR =~ ^[A-Z]{1}[a-z]+$ ]]` ?
|
||||
What advantage does Bash provide when testing parts of a script?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
`freeCodeCamp`
|
||||
Bash scripts must be compiled before testing
|
||||
|
||||
---
|
||||
|
||||
`FreeCodeCamp`
|
||||
You can only test scripts using an IDE
|
||||
|
||||
---
|
||||
|
||||
`freecodecamp`
|
||||
Bash automatically generates test cases
|
||||
|
||||
#### --answer--
|
||||
|
||||
`Freecodecamp`
|
||||
Script sections can be pasted directly into the terminal for testing
|
||||
|
||||
### --question--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user