# # This script can be run with either a Bourne shell or a C shell. # # This prepends $HOME/bin to the PATH variable. Please do not write # scripts that do tricks like this. This gives new meaning to the # word "obfuscated". # # This line runs only in Bourne shells. # # In Bourne shell, the backslash quotes the following double quote mark, so # it prints a double quote to /dev/null, executes the line, then prints a # backslash, a double quote, and another backslash to /dev/null. # # In C shell, the backslash is just a normal character inside a string, so the # following double quote mark ends the string. The third double quote mark # reopens it. This string closes prior to the HOME variable, but that's still # legal in C shell (assuming HOME and PATH are both defined as they should be), # so the contents of these variables and the text between them is concatenated # onto the previous strings. The next double quote mark starts a string again, # which includes the single quote and the following backslash before ending at # the double quote mark in the second echo statement. Finally, the backslash # serves to quote the following single quote mark since it is not in a # string). Thus, the single quote is treated as a literal character. The # resulting line is sent to /dev/null. # echo "\"" > /dev/null; export PATH="$HOME/bin:$PATH"; echo '\"\' > /dev/null # This line runs only in C shells. # # In Bourne shell, the backslash causes the following double quote mark to be # treated as a literal character. The remaining text up to the third double # quote mark is part of the string. Because the ${HOME} construct is legal # in Bourne shell (though not the normal way of printing a variable), the # contents of the HOME variable are concatenated, followed by the text after # it and the contents of the PATH variable. The next double quote mark starts # a new string containing a semicolon, the word "echo", and the following # space. The double quote that follows the word "echo" ends the string. The # backslash quotes the double quote mark that follows it, causing it to be # treated as a literal character that is concatenated onto the previous string. # The resulting line of text is then sent to /dev/null. # # In C shell, because backslashes inside strings do not quote the character # that follows them, the first backslash is treated as a literal character, and # the double quote mark after it ends the string. Thus, a backslash is sent to # /dev/null. Next, the setenv instruction is interpreted as you would expect. # Finally, as before, the double-quote-backslash-double-quote construct is # interpreted as a string containing only a backslash, which is sent to /dev/null. # echo "\" > /dev/null; setenv PATH "${HOME}/bin:${PATH}"; echo "\" > /dev/null echo "PATH IS $PATH"