read -r -p "put an option: " option
echo $option
this works but shellcheck gives me:
In POSIX sh, read -p is undefined.
How to get user input with a prompt into a variable in a posix compliant way?
You could use read without -p:
printf "put an option: " >&2
read -r option
printf '%s\n' "$option"
printf or echo? I mean, can't this be handled by read only? thanks
shellcheck gives you that warning when you target sh, but common implementations (e.g. dash, busybox ash) actually support prompting with read -p. It won't work, however, in zsh and, I think, in ksh88 and derivatives (and in the original Bourne shell).
-p but if you want to be pure POSIX sh you can't use it. If you know it wont be an issue you can ignore certain shellcheck rules.