Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions docs/books/learning_bash/07-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,21 @@ Whatever the loop used, the commands to be repeated are placed **between the wor

The `while` / `do` / `done` structure evaluates the command placed after `while`.

If this command is true (`$? = 0`), the commands placed between `do` and `done` are executed. The script then returns to the beginning to evaluate the command again.
When the evaluated command is true:

When the evaluated command is false (`$? != 0`), the shell resumes the execution of the script at the first command after done.
```
$? = 0
```

the commands placed between `do` and `done` are executed. The script then returns to the beginning to evaluate the command again.

When the evaluated command is false:

```
$? != 0
```

the shell resumes the execution of the script at the first command after done.

Syntax of the conditional loop structure `while`:

Expand Down Expand Up @@ -140,7 +152,13 @@ done

The `until` / `do` / `done` structure evaluates the command placed after `until`.

If this command is false (`$? != 0`), the commands placed between `do` and `done` are executed. The script then returns to the beginning to evaluate the command again.
When the evaluated command is false:

```
$? != 0
```

the commands placed between `do` and `done` are executed. The script then returns to the beginning to evaluate the command again.

When the evaluated command is true (`$? = 0`), the shell resumes the execution of the script at the first command after `done`.

Expand Down