I want to manipulate the expanded value of a variable that has been selected from an array after user input. Here's what I mean:
$ ./myscript.sh url2
#!/bin/bash array=(Sigil wp2epub csskit) Sigil = "https://github.com/Sigil-Ebook/Sigil.git" csskit = "https://github.com/mattharrison/epub-css-starter-kit.git" wp2epub = "https://github.com/mrallen1/wp2md.git" if [ -z $1 ]; then echo "This script needs at least one parameter!" exit 1 fi if [ $1 = Sigil ]; then ans=$Sigil # expanded elif [ $1 = csskit ]; then ans=$csskit # expanded elif [ $1 = wp2epub ]; then ans=$wp2epub # expanded else echo "Please inform one of \ Sigil, csskit or wp2epub!" fi git clone $ans
The script checks user input ($1), compares it to the array of possible variables, if found it retrieves the expanded value of that variable as the answer and then uses the expanded value (not the variable name).
I have been trying this for days, but my limited bash scripting abilities have not been enough...
Thanks in advance.
Per @terdon request: I want the user to inform the name of the variable in the array, which will be human friendly.
The variables are actually the names of packages that need to be fetched from github (git clone) and then recompiled and reinstalled.
Actual usage would be:
$ ./update.sh Sigil # Sigil is one of the variables