Arithmetic expansion in rediretion word is evaluated twice

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Arithmetic expansion in rediretion word is evaluated twice

Oğuz
See:

    $ unset foo
    $ : <$((foo+=42))
    bash: 84: No such file or directory
    $ echo $foo
    84

Reproducible on 4.4.20 and 5.0.11, couldn't try on development version
because since the last push it doesn't compile


--
Oğuz
Reply | Threaded
Open this post in threaded view
|

Re: Arithmetic expansion in rediretion word is evaluated twice

Chet Ramey
On 6/1/20 3:34 PM, Oğuz wrote:

> See:
>
>     $ unset foo
>     $ : <$((foo+=42))
>     bash: 84: No such file or directory
>     $ echo $foo
>     84
>
> Reproducible on 4.4.20 and 5.0.11, couldn't try on development version
> because since the last push it doesn't compile

How about an error message from the compile failure?

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

Reply | Threaded
Open this post in threaded view
|

Arithmetic expansion in rediretion word is evaluated twice

Oğuz
1 Haziran 2020 Pazartesi tarihinde Chet Ramey <[hidden email]> yazdı:

> On 6/1/20 3:34 PM, Oğuz wrote:
> > See:
> >
> >     $ unset foo
> >     $ : <$((foo+=42))
> >     bash: 84: No such file or directory
> >     $ echo $foo
> >     84
> >
> > Reproducible on 4.4.20 and 5.0.11, couldn't try on development version
> > because since the last push it doesn't compile
>
> How about an error message from the compile failure?
>
> It was something about underlying $RANDOM functions in variables.c,
tomorrow I can mail the full error messages.

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


--
Oğuz
Reply | Threaded
Open this post in threaded view
|

Re: Arithmetic expansion in rediretion word is evaluated twice

Oğuz
Below is the error message from the compilation failure after git pull && make:

variables.o: In function `get_urandom':
/home/oguz/.local/src/bash/variables.c:1406: undefined reference to
`get_urandom32'
variables.o: In function `assign_random':
/home/oguz/.local/src/bash/variables.c:1356: undefined reference to `sbrand'
variables.o: In function `get_random_number':
/home/oguz/.local/src/bash/variables.c:1376: undefined reference to `brand'
/home/oguz/.local/src/bash/variables.c:1371: undefined reference to `seedrand'
/home/oguz/.local/src/bash/variables.c:1376: undefined reference to `brand'
variables.o: In function `initialize_shell_variables':
/home/oguz/.local/src/bash/variables.c:607: undefined reference to `seedrand'
/home/oguz/.local/src/bash/variables.c:608: undefined reference to `seedrand32'
collect2: error: ld returned 1 exit status
Makefile:581: recipe for target 'bash' failed
make: *** [bash] Error 1

On Mon, Jun 1, 2020 at 11:17 PM Oğuz <[hidden email]> wrote:

>
>
>
> 1 Haziran 2020 Pazartesi tarihinde Chet Ramey <[hidden email]> yazdı:
>>
>> On 6/1/20 3:34 PM, Oğuz wrote:
>> > See:
>> >
>> >     $ unset foo
>> >     $ : <$((foo+=42))
>> >     bash: 84: No such file or directory
>> >     $ echo $foo
>> >     84
>> >
>> > Reproducible on 4.4.20 and 5.0.11, couldn't try on development version
>> > because since the last push it doesn't compile
>>
>> How about an error message from the compile failure?
>>
> It was something about underlying $RANDOM functions in variables.c, tomorrow I can mail the full error messages.
>
>> --
>> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>>                  ``Ars longa, vita brevis'' - Hippocrates
>> Chet Ramey, UTech, CWRU    [hidden email]    http://tiswww.cwru.edu/~chet/
>
>
>
> --
> Oğuz
>


--
Oğuz

Reply | Threaded
Open this post in threaded view
|

Re: Arithmetic expansion in rediretion word is evaluated twice

Chet Ramey
On 6/2/20 1:18 AM, Oğuz wrote:
> Below is the error message from the compilation failure after git pull && make:

You have to run configure again to remake the Makefiles.

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

Reply | Threaded
Open this post in threaded view
|

Re: Arithmetic expansion in rediretion word is evaluated twice

Chet Ramey
In reply to this post by Oğuz
On 6/1/20 3:34 PM, Oğuz wrote:
> See:
>
>     $ unset foo
>     $ : <$((foo+=42))
>     bash: 84: No such file or directory
>     $ echo $foo
>     84

Yes. The redirection is evaluated once for the open and again for the
error message.

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

Reply | Threaded
Open this post in threaded view
|

Re: Arithmetic expansion in rediretion word is evaluated twice

Dale R. Worley
Chet Ramey <[hidden email]> writes:

> On 6/1/20 3:34 PM, Oguz wrote:
>> See:
>>
>>     $ unset foo
>>     $ : <$((foo+=42))
>>     bash: 84: No such file or directory
>>     $ echo $foo
>>     84
>
> Yes. The redirection is evaluated once for the open and again for the
> error message.

That does seem rather a bug, or at least, a poor error message.  Is it
hard to save the string that was attempted to be opened?

Dale

Reply | Threaded
Open this post in threaded view
|

Re: Arithmetic expansion in rediretion word is evaluated twice

Chet Ramey
On 6/2/20 9:14 PM, Dale R. Worley wrote:

> Chet Ramey <[hidden email]> writes:
>> On 6/1/20 3:34 PM, Oguz wrote:
>>> See:
>>>
>>>     $ unset foo
>>>     $ : <$((foo+=42))
>>>     bash: 84: No such file or directory
>>>     $ echo $foo
>>>     84
>>
>> Yes. The redirection is evaluated once for the open and again for the
>> error message.
>
> That does seem rather a bug, or at least, a poor error message.  Is it
> hard to save the string that was attempted to be opened?

It's clumsy. The code isn't really structured to make this easy. I'll put
it on the list to take a look at.

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