using #! and a different shell

Jonathan I. Kamens jik at athena.mit.edu
Fri Feb 22 12:35:33 AEST 1991


% cat echo-args.c
#include <stdio.h>

main(int argc, char *argv[])
{
     if (! argc) {
          printf("There are no arguments.\n");
     }
     else {
          printf("The arguments are:");
          while (argc--) {
               printf(" %s", *argv++);
          }
          printf("\n");
     }
     exit(0);
}
% cat use-echo-args
#!/tmp/echo-args

exit 0
% ./use-echo-args foo bar baz
The arguments are: echo-args ./use-echo-args foo bar baz

This is on BSD 4.3; I doubt it's significantly different on other platforms
that allow #!.  I guess this is why "#!/bin/awk -f" works.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.wizards mailing list