Special tip: If you put one leading space before the <nowiki>, the linefeeds in your script will be handled correctly. Give it a try:
{one space here}<nowiki> # foo # bar # blat </nowiki>
As a more heavy-handed solution, you could install http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi which not only preserves formatting but also highlights your bash keywords.
DanB
-----Original Message----- Comments in the bash script are being read as a numbered list.
The script builds some sections of preformatted text so those sections are being handled as such instead of displaying the tags.
Line feeds are all messed up since it's a bash shell script.