I have a project I''m trying to package which uses git submodules extensively.

The fact that 'git archive' can't already deal with this amazes me but I recently discovered the 'git submodule foreach' command which seemed to be able to handle what I needed. 

Or so I thought...

The foreach command only expands its internal variables with single ('') quotes but of course bash variables only work with double ("") quotes. 

Unless there's some serious security consideration, WHY would you make it impossible to mix the internal and bash variables?!?!?!?

Here's part of the script I'm having issues with:
git submodule foreach --recursive 'git archive --verbose --prefix=$prefix-$tag/$sm_path/ --format tar HEAD --output $tempdir/$prefix-sub-$sha1.tar'

The $sm_path is the path to the submodule within the main git repository which I need for proper archiving. 

Any ideas?

Thanks,
Richard