I'm using foreach to retrieve subfolder names that matches a_condition*, following works fine:foreach i (a_condition*)    echo $iendIt will print a_condition1a_condition2...But when I try not hard code a_conditon* like: set condition = a_condition*foreach i ($condition)   echo $iendIt will only print the first value, why is this happening?
foreach traversing matching conditions stored in a variable
shell script;csh
In all the implementations/versions of csh that I know:set condition = a_condition*is the same as:set condition = (a_condition*)That is it creates an array containing all the filenames resulting from the expansion of the a_condition* glob. I checked with the original 1979 csh implementation in 2BSD on a PDP11 emulator, and it was the same there.The behaviour you describe looks as if that line was interpreted asset condition = a_condition1 a_condition2 a_condition3...That is, defining condition as a variable with value a_condition1 and a variable called a_condition2, then one called a_condition3... I don't know of any csh implementation that behaves like that and I would find it unlikely that such an implementation exists given that the original implementation didn't, but in case it is, you could try doing:set condition = (a_condition*)to see if that makes a difference. That would also be more self-descriptive.In any case, if you do want that glob to be expanded at the time of assignment and the loop to loop over the elements, the syntax should be:set condition = (a_condition*)foreach i ($condition:q)  echo $i:qendAnd if you want condition to contain the a_condition* string, and that string to be expanded as a glob at the time of the loop, that would be:set condition = 'a_condition*'foreach i ($condition)  echo $i:qend