For example, here I use
to avoid having to quote
I typed the
The properly quoted alias definition is sent to the standard output. That line is what you would use to define the alias. 
And here are the quote and makealias aliases themselves:
alias quote "/bin/sed -e 's/\!/\\\!/g' \ -e 's/'\\''/'\\'\\\\'\\''/g' \ -e 's/^/'\''/' -e 's/"\$"/'\''/'" alias makealias "quote | /bin/sed 's/^/alias \!:1 /' \!:2*"
Pretty gross, but they do the job.
- in comp.unix.questions on Usenet, 17 February 1991