1
read user input problem
(programming.dev)
Do this instead to treat name as a locally scoped variable:
foo() {
local name="$1"
read -r -p "delete $name (default is no) [y/n]? " choice
choice="${choice:-n}"
echo "\$choice: $choice"
}
printf "%s\n" "foo" "bar" "baz" "eggs" "spam" | while read -r name; do
foo "$name"
done
Talk about the Bash Shell and Bash scripting