I am modifying a script that uses a getopts to read in options. One of the options allows to user to narrow down the files searched. The user can specify a pattern like *.c*
for all files of type .c and .cpp.
the script xxx is called like this:
xxx -n *.c*
in this logic:
while getopts ":l:n:d:s" opt; do
case $opt in
l ) LIB=$OPTARG ;;
d ) SEARCH_DIRS=$OPTARG ;;
n ) NAME="$OPTARG" ;;
s ) SHOW="" ;;
if I say NAME='$OPTARG', then I get the literal '$OPTARG'. If I put "$OPTARG", in the script, when option n is saved in a variable NAME, instead of NAME being equal to '*.c*', NAME is equal to the first file with a type starting with c (*.c*) found in the directory from which I am executing xxx. It is like it is interpreting the regular expression before saving it in variable NAME.
How can I the literal '*.c*' to be stored in NAME?