|Syntactic Confectionery Delight|
shebang anomalyby perlboy_emeritus (Sexton)
|on Apr 18, 2018 at 21:09 UTC||Need Help??|
perlboy_emeritus has asked for the wisdom of the Perl Monks concerning the following question:
I run Perl natively in macOS (v5.18.2) and in perlbrew (v5.20.3) and in debian in a VirtualBox vm (v5.24.1). The Perl code is common by design, meant to be portable and shared by all of these separate Perl environments, so my shebang line is:#!/usr/bin/env perl -w or #!/usr/bin/env perl -wd
depending on whether I wish to debug. This shebang works correctly in macOS, either the native perl or the perlbrew perl but in debian env does not like either the -w or the -wd arguments. This, despite the (relatively) common man pages for env that assert that the command handed to env can take arguments, as in:
debian:env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
When I run perl scripts shared from macOS in debian I have to remove -w or -wd, otherwise I get:/usr/bin/env: 'perl -w': No such file or directory
The single quotes in that error message are from bash, not my script. I have tried to quote -w and -wd but explicitly quoting those arguments does not change the outcome. The bash shell or env or whatever are treating -w and -wd as the names of files and failing to find either, barf that error message. It is important that I be able to share Perl scripts between all of these execution environments so the shebang must be the same in all. What is debian env doing that the native macOS env is not? Is this possibly a bug in GNU env (v8.26)?
I suppose, technically, this is not a Perl question, so perhaps I should post this to stack overflow or some other technical site, but I thought I'd try Monks first.