How can I use drush dd in bash script?
There are several ways to specify which Drupal site Drush will target; the alias is probably the simplest.

The second option is more verbose, but it does not require an alias file.  Run:

$(drush --root=/path/to/drupal --uri=http://mysite.com dd my_theme)


You can do the same thing with a slightly different syntax:

$(drush /path/to/drupal#mysite.com dd my_theme)


You can also specify the Drupal site implicitly, by setting the cwd to the folder that contains the settings.php file for your site:

cd /path/to/drupal/sites/default # or /path/to/drupal/sites/mysite.com, as appropriate
$(drush dd my_theme)


A distant fourth option would be to use the site-set command; that would be a bad idea, though, as it uses the current process id to identify the filename that stores the current Drupal site.  If your bash script created any subprocesses (e.g. by wrapping sections of the script in parenthesis, using $(), using backticks, etc.), then commands inside the subprocess will "forget" the currently set site.

For example, the following script will only print the site that was set once; the portion of the script inside parenthesis fails to find the set site:

drush site-set @foo_alias
echo "process $BASHPID"
drush ev 'return drush_sitealias_site_get();'
(
  echo "subprocess $BASHPID"
  drush ev 'return drush_sitealias_site_get();'
)


In a script, you are better off putting the site specification into a variable, and explicitly use that variable with every invocation of Drush.