With any POSIX-like shell, assuming you want to run the command if $i does not contain a period as your example suggests, you'd write it:
case $i in
(*.*) ;; # contains "."s, do nothing
(*) drush "$i" command;;
esac
Note that with $(drush site-alias) being left unquoted, split+glob is performed on it. The splitting, which you want, being done on characters of $IFS (space, tab and newline by default (plus NUL in zsh), and the globbing, which you don't want would turn a /* word for instance into all the non-hidden files or directories in /.
On a GNU system, and with a shell with support for Ksh-style process substitution such as the GNU shell (bash), and assuming that command outputs one site-alias per line, you could do:
xargs -rd '\n' -a <(drush site-alias | grep -vF .) -I@ drush @ command
That has several advantages:
- no globbing
- properly splits on newline and newline only regardless of what
$IFShappens to contain - doesn't store the whole output in memory and starts to run
drushcommands as soon asdrush site-aliasstarts to output something - if any of the
drush commandfails, the failure will be reflected onxargs's exit status.
Note that the failure of drush site-alias if any is still ignored.
With zsh, you could do:
autoload zargs
site_aliases=( ${(f)"$(drush site-alias)"} ) || exit
zargs -I@ -- ${site_aliases:#*.*} -- drush @ command
Where:
- we also split on newline only by using the
fparameter expansion flag (empty lines are discarded). - we handle the failure of
drush site-alias(here by exiting the script) ${(M)site_aliases:#*.*}filters out (add aMparameter expansion flag to filter in instead) the elements that contain.- like
xargs,zargsreturns a failure exit status if and of the commands fails.