I have a simple code that runs a case statement that will grow over time. I want other users to update the possible cases but I don't want them to update the code. Is it possible to source in the options from a file called optionsfile.txt?
Current sample:
read input
case $input in
option1 )
echo option1 ;;
option2 )
echo option2 ;;
esac
Changed to:
read input
case $input in
Source in file here optionsfile.txt
esac
So the contents of the optionsfile.txt will look like this:
option1 )
echo option1 ;;
option2 )
echo option2 ;;
So I ended up using a script that gets called if the date time stamp is updated on the optionsfile.txt that makes a function. That function is sourced into the main code.
#!/bin/bash
cat <<Part1
userstuff() {
read input
case $input in
Part1
cat ./optionsfile.txt
cat <<Part2
esac
}
Part2
Thank you.