bug-bash
[Top][All Lists]
Advanced

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

Re: TIMEFORMAT in time ( )


From: Eduardo A . Bustamante López
Subject: Re: TIMEFORMAT in time ( )
Date: Mon, 17 Oct 2016 02:30:30 -0500
User-agent: Mutt/1.5.20 (2009-12-10)

The attached patch "fixes" this:

    hp% ./bash -c 'time (TIMEFORMAT=y)'
    
    real    0m0.001s
    user    0m0.000s
    sys     0m0.000s
    hp% bash -c 'time (TIMEFORMAT=y)' 
    y

Disclaimer: I don't know if it's a good patch. It may break stuff.

This problem is caused due to bash passing `time ( ... )' as a COMMAND with
type = cm_subshell and flags = CMD_TIME_PIPELINE to execute_command_internal,
but since the case to handle type = cm_subshell is before the case to handle
flags = CMD_TIME_PIPELINE, the program forks, the time_command is executed
inside the new process and we all know what happens next.

My patch just adds a special case for this situation, and passes the command
directly to time_command.

I guess it might be better to just move the block of code handling the general
case when flags = CMD_TIME_PIPELINE, but I don't know if this will have any
undesired consequences.

Attachment: cm_subshell_time.patch
Description: Text document


reply via email to

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