From 33db52885e3bed0355654336079b0a74394e0ea9 Mon Sep 17 00:00:00 2001 From: Lucas Larson <91468+LucasLarson@users.noreply.github.com> Date: Fri, 27 Jan 2023 17:16:33 -0500 Subject: [PATCH] add POSIX-compliant alternative --- SC3009.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/SC3009.md b/SC3009.md index cf1ce1e..3c00c12 100644 --- a/SC3009.md +++ b/SC3009.md @@ -12,7 +12,19 @@ Here, `$i` expands to `{1..5}`. It does **not** expand to the sequence `1 2 3 4 ### Correct code: -For simple sequences of numbers, you may use the `seq` command, e.g. `seq 1 5`. +```sh +#!/bin/sh +i=1 +# while $i ≤ 5 ... +while [ "${i}" -le 5 ]; do ... + + # something that will occur 5 times + + i=$((i + 1)) +done +``` + +You can also use the `seq` command, e.g. `seq 1 5`, but `seq` is not a POSIX utility. ### Rationale: