escape bash characters when generating tmp script