bug-bash
[Top][All Lists]
Advanced

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

Re: bash-source closes file descriptor before reading from it on Darwin


From: Chet Ramey
Subject: Re: bash-source closes file descriptor before reading from it on Darwin
Date: Wed, 18 Sep 2013 12:04:29 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

On 9/17/13 8:47 PM, Andrew de Andrade wrote:

> Bash Version: 4.2
> Patch Level: 45
> Release Status: release
> 
> Description:
> When using source with process substitution, where the command
>  writes to stdout, source closes the file descriptor created by
> the process substitution before reading from it.
> 
> AFAIK this only occurs on Darwin. This impacts bash-completion
> used by npm and node-tabtab.
>  https://github.com/isaacs/npm/blob/master/lib/completion.js#L163
> 
> Repeat-By:
> Create a script or executable that writes another script to
> stdout. Execute that command like so...
>  source <(my_command)
> ... then check if the script written to stdout was actually
> sourced.

Can you give me something that will allow me to reproduce the problem
more easily?  I can't reproduce it with something like this:

foo()
{
        echo "bar()"$'\n'"{ echo in bar;"$'\n'"}"
        echo echo one
        echo echo two
        echo echo three
        echo echo inside
        echo type bar
        echo bar
}

source <(foo)
echo outside
type bar
echo $?

Does it take a script of a certain size to trigger the problem?  If the
problem is as you describe it should not work anywhere.

I happen to be using exactly the same release of MacOS X and kernel version
you are.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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