bug-coreutils
[Top][All Lists]
Advanced

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

env behavior incorrect


From: Jens Elkner
Subject: env behavior incorrect
Date: Mon, 2 Jun 2003 08:39:55 +0200 (MEST)

Hi,

unfortunately env is not POSIX, or to be more specific, not "The Open Group
Base Specifications Issue 6 IEEE Std 1003.1, 2003 Edition" compliant on Linux.
(see http://www.unix-systems.org/version3/iso_std.html )

E.g.: filename.env
#!/usr/bin/env -i command args ...

should exec command with the specified args with an empty env. 

However, env tries to execute $aPath/'-i command args ...', which usually
fails or at least executes a non-intended command. 

This is probably caused by the very weird #! interpreter check implementation
in the Linux kernel (see fs/binfmt_script.c ), which passes the interpreter
as argv[0], everything after it as argv[1] and $pathTo/filename.env as argv[2].

Since the kernel people do not wanna fix that creepy implementation, env should
1) create a new char argv1[] and
2) resolve argv[1] into argv1[]
3) prepend argv1[] with argv[0]
4) append argv[2] to argv1[] 
5) use argv1[] to check for opts and pass it to command, if a command was
   specified

Furthermore according to XBD Utility Syntax Guidelines, long option support
(i.e. --ignore-environment,  --unset) should be dropped.

Last but not least - why not
    ...
    static char *pointer2null = NULL;
    ...
    main(....) {
        ...
        if (ignore_environment)
            environ = &pointer2null;
        ...
    }
    and drop the dummy_environ/uneccessary env copy stuff ... ?

   
What do you think ?

Regards,
jens.
-- 
+---[ Jens Elkner ]---------[ IMS GmbH, Abt. Server/Netzwerkmanagement ]--+
| Sandtorstr. 23                       +49 391 54486 19230                |
| 39106 Magdeburg                       address@hidden                |
| GERMANY                             http://www.imsgroup.de/             |
+-------------------------------------------------------------------------+




reply via email to

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