How do I prevent bash $ substitution?

I'm trying to preserve $if below and
would like the following to output
$if

bash is getting in the way by doing
$ substitution

$ sed -e 's:\\$:\\$:g' <<ENDOFFILE  
> $if  
> ENDOFFILE  

or

$ tr '$' '\$' <<ENDOFFILE  
> $if  
> ENDOFFILE  

Is there a way to preserve $keywords
to stdout without explicitly escaping
them out in stdin?

Should I switch to another shell before attempting this?


I'm not sure what you are trying to do but bash is performing parameter expansion in your here document because the delimiter ENDOFFILE. If you were to change it to 'ENDOFFILE' bash would not expand.