Shell Script – Why Escape Trivial Characters?

kshquotingshell-script

I just opened a legacy shell script (written in old ksh88 on Solaris) and found the following repeated all throughout the code:

[ -f $myfile ] && \rm -f $myfile

The escaping backslash strikes me as odd.

I know it is deliberate, since this kind of (apparently useless) escaping is repeated all throughout the code. The original author is long gone, I cannot get in touch with him to ask him.

Is this simply a funny idiosyncrasy of the author or is it some sort of deprecated good practice that made sense at some point in time? Or maybe is actually the recommended way of doing things and I'm missing something altogether?

Best Answer

This is used for alias protection:

$ ls
.bashrc  a  b

$ alias ls
alias ls='ls $LS_OPTIONS'

$ \ls
a   b
Related Question