Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Isaac Good <[email protected]>
  • Loading branch information
glennj and IsaacG authored Nov 19, 2024
1 parent a4db052 commit 5291bfb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions concepts/conditionals/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Some typical conditional expressions include:
[ "$num1" -eq "$num2" ] # arithmetic comparisons
```

There are many more operations available: they are listed in the [Bash Conditional Expressions][cond-expr] section of the manual.
There are many more operations available; they are listed in the [Bash Conditional Expressions][cond-expr] section of the manual.

~~~~exercism/note
In the examples above, notice that all the variables are quoted.
Expand Down Expand Up @@ -114,15 +114,15 @@ if [ -n $str ]; then echo "not empty"; else echo "empty"; fi
## "[[" Keyword

The [`[[...]]` conditional construct][cond-construct] is not a _command_, it is a **keyword**.
This means that, although it is handled like any other command, it can have special parsing rules.
This means that, although it is handled like any other command, it has special parsing rules.
What's special about `[[` is that the variables expanded within it are **not** subject to word splitting or filename expansion.
That means this command acts as you expect, even without quoting.

```bash
if [[ -n $str ]]; then echo "not empty"; else echo "empty"; fi
```

`[[` works with all the conditional expressions that `test` and `[` can handle.
`[[` supports all the conditional expressions that `test` and `[` can handle.
In addition, `[[` provides

* the `=~` regular-expression matching operator,
Expand Down

0 comments on commit 5291bfb

Please sign in to comment.