bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: env (GNU coreutils) 5.93 patch


From: Eric Blake
Subject: Re: env (GNU coreutils) 5.93 patch
Date: Mon, 02 Jan 2006 17:14:15 +0000

> If I crick doing "env" hacking, are you able to create a new command?

You are free to hack env, since it is open source, and you are free to
write your own commands.  However, it is very doubtful that coreutils
will ever include your hacks, or adopt your proposed 'exe' utility, since
no one else has expressed a need for working around the limitations
of #! lines.  Also, remember that POSIX specifically states that #! lines
are not to be used by strictly conforming applications, because there
are so many incompatible gotchas in using them between various
platforms and shells.

> For instance, the command named "exe" separates the argument of each
> space interpreting #! line.
> It is possible to write as follows:
> #! /bin/exe awk -f

Now you have a chicken and egg problem.  Since your proposed /bin/exe
is not standardized, it is just as likely that /bin/exe won't exist as it
would be that /bin/awk does exist.  As has already been explained to you,
your only PORTABLE solution to install an awk script that invokes awk with
an argument using a #! interpreter line is to install your awk script with
a sed substitution that finds the correct location of awk for the system
you are installing on, and edits the #! line accordingly.

Another possible alternative is to use #! /bin/sh, then to find a
way in the first few lines of the script to 'exec awk -f' if sh is the
current intepreter, and skip those lines if awk is the interpreter (the
perl documentation gives several examples of ways to do this for
perl scripts, such as the idea shown below from 'perldoc perlrun';
I have not ever seen this type of hack for an awk script, but think
it should be possible).

#!/bin/sh -- # -*- perl -*- -p
eval 'exec perl -wS $0 ${1+"$@"}'
    if $running_under_some_shell;

--
Eric Blake




reply via email to

[Prev in Thread] Current Thread [Next in Thread]