46 lines
1023 B
Markdown
46 lines
1023 B
Markdown
# hello-world.sh
|
|
|
|
Reference example script — prints a greeting. Demonstrates the required
|
|
structure every script in this repo must follow: `common.sh` sourcing,
|
|
`SCRIPT_HELP` heredoc, `--help` handling, and argument parsing with
|
|
`common::die` on invalid input.
|
|
|
|
**This is not a real utility.** Copy its structure when writing an actual
|
|
script; don't invoke it from other scripts or automation.
|
|
|
|
## What it does
|
|
|
|
Prints `Hello, <name>!` to stdout, where `<name>` defaults to `world` or
|
|
whatever is passed via `--name`.
|
|
|
|
## Requirements
|
|
|
|
- Bash 4+ (uses `set -euo pipefail`, no external commands beyond common.sh)
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
./examples/hello-world.sh [OPTIONS]
|
|
```
|
|
|
|
### Options
|
|
|
|
| Option | Description |
|
|
|--------|-------------|
|
|
| `-h`, `--help` | Show help message and exit |
|
|
| `-n`, `--name NAME` | Name to greet (default: `world`) |
|
|
|
|
## Examples
|
|
|
|
```bash
|
|
# Default greeting
|
|
./examples/hello-world.sh
|
|
# → Hello, world!
|
|
```
|
|
|
|
```bash
|
|
# Custom name
|
|
./examples/hello-world.sh --name Danail
|
|
# → Hello, Danail!
|
|
```
|