help-bash
[Top][All Lists]
Advanced

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

Re: why does </proc/self/environ not work in bash?


From: Chet Ramey
Subject: Re: why does </proc/self/environ not work in bash?
Date: Wed, 14 Feb 2024 09:13:38 -0500
User-agent: Mozilla Thunderbird

On 2/14/24 8:07 AM, Zachary Santer wrote:
On Tue, Feb 13, 2024 at 2:27 PM Chet Ramey <chet.ramey@case.edu <mailto:chet.ramey@case.edu>> wrote:

    This is a comment from the code as it existed in July 1989:

            /* Hopefully this command is defined in a disk file somewhere.

               1) fork ()
               2) connect pipes
               3) close file descriptors 3-NOFILE
               4) look up the command
               5) do redirections
               6) execve ()
               7) If the execve failed, see if the file has executable mode
    set.
               If so, and it isn't a directory, then execute its contents as
               a shell script.

               Note that the filename hashing stuff has to take place up here,
               in the parent.  This is probably why the Bourne style shells
               don't handle it, since that would require them to go through
               this gnarly hair, for no good reason.
            */

    It persists in the source to this day (except for the closing files bit).


Pardon my ignorance, but I don't understand how that relates to when the redirection filename argument gets parsed, specifically.

It means that the function that expands redirection words and manipulates
files and file descriptors, which still performs more or less the same
function today, was called post-fork from the very beginning. It doesn't
have anything to do with parsing.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

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