Dan said:
In said:
[C source files as executables on *nix]
A shell script need not start with #! to be executable on at
least some Unix-like systems. The default interpreter is
The default interpreter is /bin/sh:
You're actually making my point: the *default* interpreter is not an
interpreter for C source code.
It's a rather silly idea, but I can imagine a shell that interprets a
subset of C in interactive mode (executing statements in main as they
are completed) and the real thing otherwise. It would also be rather
ugly, I suspect, but sessions like this are feasible:
/* The Real C Shell Interpreter */
/* user:/home/user % */ /*
A sample session; all others comments are output, mainly prompts.
*/
/* user:/home/user % */ #include <stdio.h>
/* user:/home/user % */ #include <math.h>
/* user:/home/user % */ int main( void ) {
/* Execution commences */
/* user:/home/user % */ puts( "\"Hello, world!\"" );
/*
"Hello, world!"
*/
/* user:/home/user % */ printf( "%f\n", pow( 4., 2.5 ) )
/* ... */ ;
/*
31.9999
*/
/* user:/home/user % */ if (0) {
/* ... */ puts( "Goodbye, cruel world.\n" );
/* ... */ return 42;
/* ... */ }
/* user:/home/user % */ char *cc = "/bin/sh";
/* user:/home/user % */ __rcsh_chdir( "some_project" );
/* user:/home/user/some_project % */ __rcsh_exec( cc, "--standard=c99",
/* ... */ "--annoying-style-advice", "--target=ds9000", "-o", "runme",
/* ... */ "main.c", NULL );
/*
/* The Real C Shell Compiler * /
char *errors[] = { "main.c: No such file or directory", 0 };
/* Compilation failed; 1 error, 0 warnings. * /
*/
/* user:/home/user % */ }
/* Session closed */
Obviously, it can't be interactive while allowing functions that have
not been defined yet to be called from main; other restrictions might
be necessary.
I'm not sure if this disqualifies an operating system from being said
to be `Unix-like', though.