Skip to content

Commit 4271b80

Browse files
committed
Better named specs from user guide
1 parent bd37aff commit 4271b80

26 files changed

+118
-19
lines changed

docs/_pages/index.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,42 @@ myCommand arg1 arg2 > "log.log"
448448
# Conditionals
449449

450450
## `if / fi`
451+
452+
- `if` conditionals are supported (`then` _is an optional keyword_)
453+
454+
```sh
455+
- if [ '$#' -eq 0 ]
456+
- comment Hello
457+
- elif [ '$#' -eq 1 ]
458+
- else
459+
- echo "Hello, world"
460+
- fi
461+
```
462+
463+
<!-- OUTPUT -->
464+
465+
```sh
466+
if [ $# -eq 0 ]
467+
then
468+
# Hello
469+
:
470+
elif [ $# -eq 1 ]
471+
then
472+
:
473+
else
474+
echo "Hello, world"
475+
fi
476+
```
477+
478+
ℹ️ Empty blocks (_or those with only comments_) automatically have a `:` added
479+
451480
## `case / option / esac`
481+
482+
483+
452484
## `[ ... ] AND / OR`
453485

486+
454487
# Loops
455488

456489
## `for`
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
source shellpen.sh
2+
3+
shellpen -
4+
5+
commandGroup1() {
6+
- if [ '$#' -eq 0 ]
7+
- comment Hello
8+
- elif [ '$#' -eq 1 ]
9+
- else
10+
- echo "Hello, world"
11+
- fi
12+
- code
13+
}
14+
15+
@spec.commandGroup1() {
16+
read -r -d '' expected <<'EXPECTED'
17+
if [ $# -eq 0 ]
18+
then
19+
# Hello
20+
:
21+
elif [ $# -eq 1 ]
22+
then
23+
:
24+
else
25+
echo "Hello, world"
26+
fi
27+
28+
EXPECTED
29+
expect { commandGroup1 } toContain "$expected"
30+
}
31+
File renamed without changes.
File renamed without changes.

examples/documentation/userGuide/example19.spec.sh renamed to examples/documentation/userGuide/Output_printf_With_Flags.spec.sh

File renamed without changes.

examples/documentation/userGuide/example18.spec.sh renamed to examples/documentation/userGuide/Output_printf_With_Formatter.spec.sh

File renamed without changes.
File renamed without changes.

examples/documentation/userGuide/example23.spec.sh renamed to examples/documentation/userGuide/Output_toFile_Arbitrary_Command.spec.sh

File renamed without changes.
File renamed without changes.

examples/documentation/userGuide/example21.spec.sh renamed to examples/documentation/userGuide/Output_toStderr_Arbitrary_Command.spec.sh

File renamed without changes.

0 commit comments

Comments
 (0)