Skip to content

Commit d73afa3

Browse files
authored
doc(README): Make shell snippet copy&paste safe (#336)
Many bash/shell snippets in the README use an environment variable `YOUR_CONTAINER_REGISTRY`, which is used as `$YOUR_CONTAINER_REGISTRY`. However, that has the downside that if users copy & paste the snippet and accidentally press enter or use a shell that doesn't allow multi- line pasting (and executes it immediately), then the variable will be replaced by an empty string, because it wasn't set before. It's good practice to make those snippets copy&paste-safe. We can achieve that by adding `:?` to the variable, which emits an error if the variable is unset or null. See https://devhints.io/bash for a bash cheat sheet. Example: ```sh docker push ${YOUR_CONTAINER_REGISTRY:?}/bookshop-srv ``` On ZSH: ``` zsh: YOUR_CONTAINER_REGISTRY: parameter not set ``` On Bash: ``` bash: YOUR_CONTAINER_REGISTRY: parameter null or not set ```
1 parent 681eb89 commit d73afa3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Use the following steps to import the project to Eclipse:
169169

170170
```${workspace_loc:bookshop-parent}```
171171

172-
Afterwards, click **Run**. This step starts the applications `main` method located in `src/main/java/my/bookshop/Application.java`.
172+
Afterward, click **Run**. This step starts the applications `main` method located in `src/main/java/my/bookshop/Application.java`.
173173

174174
## Using IntelliJ Idea (Community and Ultimate)
175175

@@ -447,7 +447,7 @@ mvn clean package -DskipTests=true
447447
```
448448

449449
```bash
450-
pack build $YOUR_CONTAINER_REGISTRY/bookshop-srv \
450+
pack build ${YOUR_CONTAINER_REGISTRY:?}/bookshop-srv \
451451
--path srv/target/*-exec.jar \
452452
--buildpack gcr.io/paketo-buildpacks/sap-machine \
453453
--buildpack gcr.io/paketo-buildpacks/java \
@@ -456,12 +456,12 @@ pack build $YOUR_CONTAINER_REGISTRY/bookshop-srv \
456456
--env BP_JVM_VERSION=17
457457
```
458458

459-
(Replace `$YOUR_CONTAINER_REGISTRY` with the full-qualified hostname of your container registry)
459+
(Replace `${YOUR_CONTAINER_REGISTRY:?}` with the full-qualified hostname of your container registry)
460460

461461
**Build Approuter Image:**
462462

463463
```bash
464-
pack build $YOUR_CONTAINER_REGISTRY/bookshop-approuter \
464+
pack build ${YOUR_CONTAINER_REGISTRY:?}/bookshop-approuter \
465465
--path app \
466466
--buildpack gcr.io/paketo-buildpacks/nodejs \
467467
--builder paketobuildpacks/builder-jammy-base \
@@ -471,7 +471,7 @@ pack build $YOUR_CONTAINER_REGISTRY/bookshop-approuter \
471471
**Build database deployer image (single tenant only):**
472472

473473
```bash
474-
pack build $YOUR_CONTAINER_REGISTRY/bookshop-hana-deployer \
474+
pack build ${YOUR_CONTAINER_REGISTRY:?}/bookshop-hana-deployer \
475475
--path db \
476476
--buildpack gcr.io/paketo-buildpacks/nodejs \
477477
--builder paketobuildpacks/builder-jammy-base \
@@ -481,7 +481,7 @@ pack build $YOUR_CONTAINER_REGISTRY/bookshop-hana-deployer \
481481
**Build sidecar image (multi tenant only):**
482482

483483
```bash
484-
pack build $YOUR_CONTAINER_REGISTRY/bookshop-sidecar \
484+
pack build ${YOUR_CONTAINER_REGISTRY:?}/bookshop-sidecar \
485485
--path mtx/sidecar/gen \
486486
--buildpack gcr.io/paketo-buildpacks/nodejs \
487487
--builder paketobuildpacks/builder-jammy-base \
@@ -493,21 +493,21 @@ pack build $YOUR_CONTAINER_REGISTRY/bookshop-sidecar \
493493
You can push all the container images to your container registry, using:
494494

495495
```bash
496-
docker push $YOUR_CONTAINER_REGISTRY/bookshop-srv
496+
docker push ${YOUR_CONTAINER_REGISTRY:?}/bookshop-srv
497497
498-
docker push $YOUR_CONTAINER_REGISTRY/bookshop-approuter
498+
docker push ${YOUR_CONTAINER_REGISTRY:?}/bookshop-approuter
499499
```
500500

501501
#### Single Tenant
502502

503503
```bash
504-
docker push $YOUR_CONTAINER_REGISTRY/bookshop-hana-deployer
504+
docker push ${YOUR_CONTAINER_REGISTRY:?}/bookshop-hana-deployer
505505
```
506506

507507
#### Multi Tenant
508508

509509
```bash
510-
docker push $YOUR_CONTAINER_REGISTRY/bookshop-sidecar
510+
docker push ${YOUR_CONTAINER_REGISTRY:?}/bookshop-sidecar
511511
```
512512

513513
### Configuration

0 commit comments

Comments
 (0)