time: Time does not parse its parameters

Bug #238061 reported by Marco R
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Gnu Bash
Fix Released
Unknown
bash (Ubuntu)
Invalid
Undecided
Unassigned
time (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: time

This is a cut and paste from a bug reported on the debian bug tracking system. since this bug hasn't been fixed in about one year and is also present in ubuntu, I am reporting it here. Maybe someone here will know how to fix it.

From: Martin Jambor <email address hidden>
To: Debian Bug Tracking System <email address hidden>
Subject: time: Time does not parse its parameters
Date: Wed, 20 Sep 2006 16:21:02 +0200

Package: time
Version: 1.7-21
Severity: important

Time does not parse its own parameters and treats everything on the
command line like the program it should run and its parameters.

For example the following works:

jamborm@cetus:~/tmp/randwrite$ time bash < /dev/null

real 0m0.005s
user 0m0.000s
sys 0m0.004s

But this does not:

jamborm@cetus:~/tmp time -f "%e" bash < /dev/null
bash: -f: command not found

real 0m0.002s
user 0m0.000s
sys 0m0.000s

OTOH, I suspect this might be a bash issue because I have just found
out that /usr/bin/time works as expected.

TIA

Martin

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16.14mj01
Locale: LANG=C, LC_CTYPE=cs_CZ (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)

Versions of packages time depends on:
ii libc6 2.3.6.ds1-4 GNU C Library: Shared libraries

time recommends no packages.

-- no debconf information

Changed in gnubash:
status: Unknown → New
Revision history for this message
Marco R (robado-m) wrote :

You can read the debian bug report page for details. But a simple workaround is to use the command "/usr/bin/time" instead of just "time". If it is not corrected, it would at least be nice to mention this in the man page.

Revision history for this message
Mika Fischer (zoop) wrote :

Hi Marco,

thanks for taking the time to report this issue.

This behavior - annoying as it may be - is however entirely expected.

Quoting from the bash manpage:
" Pipelines
       A pipeline is a sequence of one or more commands separated by the char‐
       acter |. The format for a pipeline is:

              [time [-p]] [ ! ] command [ | command2 ... ]
[...]
       If the time reserved word precedes a pipeline, the elapsed as well as
       user and system time consumed by its execution are reported when the
       pipeline terminates. The -p option changes the output format to that
       specified by POSIX. The TIMEFORMAT variable may be set to a format
       string that specifies how the timing information should be displayed;
       see the description of TIMEFORMAT under Shell Variables below."

So bash has an internal version of "time" and it only accepts -p as a parameter.

/usr/bin/time is a separate program, and, as you noticed, it works correctly if you make sure *it* is called and not bash's version.

If you specifically want to change the output format, the bash variable TIMEFORMAT may be of use to you. See also question G4 of the bash FAQ here: http://tiswww.case.edu/php/chet/bash/FAQ

As for documenting this in the manpage, it already is. Quoting from time(1):
"Users of the bash shell need to use an explicit path in order to run the external time command and not the shell builtin variant. On system where time is installed in /usr/bin, the first example would become /usr/bin/time wc /etc/hosts"

I hope this clears everyhting up :)

Changed in bash:
status: New → Invalid
Changed in time:
status: New → Invalid
Revision history for this message
Marco R (robado-m) wrote :

Thanks a lot for your help Mika.

I guess I missed that part of the man page. Sorry, my mistake.

Changed in gnubash:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.