curlfish/curlfish.c

35 lines
1.6 KiB
C
Raw Normal View History

2020-09-08 01:16:08 -04:00
/*
** This is curlfish, a program just about as simple as they come.
** The name comes from an abreviation of, then an expansion of, "CRLF shell"
** (CRLF SHELL -> crlfsh - > curlfish)
**
**
** In fact, the curlfish program is no more than "Hello World!". The real
** hack is in filenames (filenames of symbolic links, actually). The actual
** binary is installed in /bin and you make multiple symlinks to it, named
** exactly the same as real script interpreters, except followed by a carriage
** return character. Thus, when a file is created under DOS or Windows, and
** has CRLF line terminations, the script has a valid interpreter to call via
** its #! line.
**
** For example, A script is created under Windows which should call /bin/ksh,
** but because it has DOS style line terminations, it actually calls
** /bin/ksh^M Usually this results in a rather cryptic message indicating
** that the interpreter does not exist. A casual inspection of the file
** does not reveal the CRLF terminations, and the user checks that /bin/ksh
** does indeed exist. If /bin/ksh^M really does exist as a symlink to
** curlfish, the user is immediately made aware of the true nature of the
** problem.
**
** I have also added a fairly distinctive return code so that if scripts that
** call curlfish are called by methods other than a direct shell invocation,
** that fact can be tested for and the error handled gracefully.
**
*/
#include <stdio.h>
int main (void)
{
printf ("\n\nYour script contains DOS-style line endings\nPlease remedy the situation and try again\n\n");
return 29;
}