I want to run perl -w using env. That works fine on the command line:
$ /bin/env perl -we 'print 'Hello, world!\n'' Hello, world!
But it doesn’t work on the shebang line in a script:
#!/bin/env perl -w print 'Hello, world!\n';
Here is the error:
/bin/env: perl -w: No such file or directory
Apparently env doesn’t understand the -w flag that I’m passing to perl. What’s wrong?
The hash-bang isn’t a normal shell command-line, the parsing and white-space handling is different – that’s what you’ve hit. See:
Basically many/most unixes put all of the remaining text after the first space into a single argument.
So:
is the equivalent of:
so you need to handle any options to the perl interpreter in some other fashion. i.e.
(as @Telemachus)