A function plus a while/shift driver
A function plus a while/shift driver
Answer
lookup() { grep -i "$1" phones.txt | sort } while [ $# -gt 0 ] do lookup "$1" shift done
The 1 in the call is the script argument; the 1 inside the body is the function argument. Positional parameters are rebound for the duration of a call.
S&K 3e ch13 §13.6–§13.7; function definition, return and local scope from POSIX.1-2024 §2.9.5