I'm having a problem here on a bash script I made. In a for loop, I iterate on all the arguments to construct a string variable that is later fed to an eval command:    for arg in $*    do        if [ $arg != $lastArg ]; then            findTarget+=-name $arg -o         else            findTarget=$(echo $findTarget | sed 's/-o$//')            break        fi    doneThe problem stems from the $*. For example when I enter *.c in the arguments, and the current folder contains files that match that pattern, the *.c argument is expanded into those files; I do not want that, I want findTarget to be concatenated with -name *.c -o, I have tried with and witout quotes, using eval, nothing seems to work. Any idea how to do this (simply if possible) ? Note: the total number of arguments can vary.This is an example of how I run the script:$ trouver.bash *.c *.f90 someStringAt the end of my for loop, the variable findTarget should read -name *.c -o -name *.f90This does not work if the *.c or *.f90 match files in the current folder...
Problem with wildcard expansion in for loop range
bash;wildcards;for
The syntax to  loop over the positional parameters is for arg do alone. $* is the concatenation of the positional parameters with the first character of $IFS, so you would be looping over one element only.Also, if you want to build a list of arguments for the find command, you need an array, not a string. And don't forget to quote your variables!So:findTarget=()or=()for argdo    [ $arg = $lastArg ] && break    findTarget+=(${or[@]} -name $arg)    or=(-o)donefind . \( ${findTarget[@]} \)Note that when you invoke your script, you need to quote the *.c... patterns as otherwise they would be expanded by the shell before being passed to the script.trouver.bash '*.c' '*.f90' someStringIf your interactive shell is zsh, you can define an alias for your command where globbing is disabled with:alias trouver.bash='noglob trouver.bash'That way, you can do:trouver.bash *.c *.f90 someStringwithout the shell expanding those *.c *.f90 globs.