bug-bash
[Top][All Lists]
Advanced

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

Re: Odd bash behaviour with time:


From: Eduardo A . Bustamante López
Subject: Re: Odd bash behaviour with time:
Date: Fri, 31 Oct 2014 18:42:40 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

> Two comments.
> 
> 1) The shell is not in posix mode.
Yep.

According to my tests, it also fails like OP reported in posix mode:

| dualbus@dualbus ~ % bash -c $'for ((i=0;i<10000;i++)); do :; done\ntime'
| 
| real    0m0.000s
| user    0m0.000s
| sys     0m0.000s
| dualbus@dualbus ~ % bash --posix -c $'for ((i=0;i<10000;i++)); do :; 
done\ntime'
| user    0m0.06s
| sys     0m0.00s
| dualbus@dualbus ~ % bash --posix -c $'head -c1000000 </dev/urandom 
>/dev/null\ntime'
| user    0m0.00s
| sys     0m0.09s
| dualbus@dualbus ~ % bash -c $'head -c1000000 </dev/urandom >/dev/null\ntime'
| 
| real    0m0.000s
| user    0m0.000s
| sys     0m0.000s
| dualbus@dualbus ~ % bash -c $'time;ls'
| bash: -c: line 0: syntax error near unexpected token `ls'
| bash: -c: line 0: `time;ls'
| dualbus@dualbus ~ % bash --posix -c $'time;ls'
| bash: -c: line 0: syntax error near unexpected token `ls'
| bash: -c: line 0: `time;ls'


> 2) In non posix mode time with no arguments is not meaningful. Best I
> can tell it always returns 0, I still maintain it should return an
> error.  
> 
> # while :; do echo Hello; done
> Let it run and run and run
> # ^C
> # time
> 
> real    0m0.000s
> user    0m0.000s
> sys     0m0.000s
> 
> 
> 
> Maybe it should be more like this:
> 
> # time
> Error, 'time' with no arguments is only meaningful in posix mode
I agree with you on this.

But, the thing is... it shouldn't be a syntax error, right? My
opinion is that

$ time
bash: usage error: blah blah

$ time; ls
bash: usage error: blah blah
foo bar baz

Should be how bash treats this, even if time is a special keyword.

Or... why not have time behave the same in non-posix mode?...
backwards compatibility is not an issue, since it's not useful right
now. And the posix mode behavior is kind of useful.



reply via email to

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