So this is my code:
#!/bin/bash
action_list='list|add|rem'
while true; do
echo "Actions include: list - show list
add - add item to list
rem - remove item from list"
read -p "Input action: " action_var
case $action_var in
${action_list} ) echo "Option $action_var is valid";;
*) echo "Option $action_var is INVALID";;
esac
echo $action_var
done
What I want is to use the case command such that, in the future if I add more options, I don't need to hardcode them in, I can just use the "action_list" variable.
But the ${action_list} ) construct does not work.
Now I tried hardcoding it like list|add|rem)... and it works.
Why wouldn't a variable work in this case?