Shell

- Files
.sh.bash.ksh.zsh- Formats as
- Ur
- Lints
- Every rule that reads its code
- In
ur.toml [format.shell]
Formatted
cart.sh, as written#!/usr/bin/env bash
# What a cart costs: the sum of each item's price times its quantity, read from a CSV file of items.
set -euo pipefail
test -f "$1" || { echo "usage: cart.sh items.csv" >&2; exit 1; }
tail -n +2 "$1" | awk -F, '{ sum += $2 * $3 } END { printf "%.2f\n", sum }' | tee --append subtotals.log
ur format --style ur cart.sh#!/usr/bin/env bash
# What a cart costs: the sum of each item's price times its quantity, read from
# a CSV file of items.
set -euo pipefail
test -f "$1" || { echo "usage: cart.sh items.csv" >&2; exit 1; }
tail -n +2 "$1" | awk -F, '{ sum += $2 * $3 } END { printf "%.2f\n", sum }' |
tee --append subtotals.log
Versions
Ur reads Shell as the profiles below name it. Name the versions a project targets in target; without it, Ur reads shell-bash-5.3.
| Profile | Dialect |
|---|---|
shell-posix-2008 | POSIX |
shell-posix-2024 | POSIX |
shell-bash-3.2 | Bash |
shell-bash-4.0 | Bash |
shell-bash-4.1 | Bash |
shell-bash-4.2 | Bash |
shell-bash-4.3 | Bash |
shell-bash-4.4 | Bash |
shell-bash-5.0 | Bash |
shell-bash-5.1 | Bash |
shell-bash-5.2 | Bash |
shell-bash-5.3 | Bash |
shell-ksh-88 | Ksh |
shell-ksh-93 | Ksh |
shell-zsh-5.9 | Zsh |