~$> function f { local opt; read -p "choose from args [ $@ ]:" opt; }
~$> f a b
-bash: read: `b ]:': not a valid identifier
The workaround I employed was
echo -ne "choose from args [ $@ ]:"; read opt;
OR
local args="$@"
read -p "choose from args [ ${args} ]:" opt;
But can someone explain why it does not work with read -p
.
Note: read -p "choose from args [ $1 ]:"
seems to work just fine.
Using Platform Cygwin and debian 9. bash version 4.4.12 and 5.0.3.