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
$IFS happens to contain
- doesn't store the whole output in memory and starts to run
drush commands as soon as drush site-alias starts to output something
- if any of the
drush command fails, the failure will be reflected on xargs'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
f parameter expansion flag (empty lines are discarded).
- we handle the failure of
drush site-alias (here by exiting the script)
${site_aliases:#*.*} filters out (add a M parameter expansion flag to filter in instead) the elements that contain .
- like
xargs, zargs returns a failure exit status if and of the commands fails.