time command doesnt recognize it's own arguments

Bug #660655 reported by AFarris01
70
This bug affects 13 people
Affects Status Importance Assigned to Milestone
time (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: time

I was trying to use the 'time' command today to get execution time from a few different programs. It seems to work just fine so long as you just invoke it as 'time COMMAND COMMAND-ARGS'... however I wanted to get more verbose output, and eventually output to a file. From the 'time' man page:
--------------------------------------
 -o FILE, --output=FILE
              Write the resource use statistics to FILE instead of to the
              standard error stream. By default, this overwrites the file,
              destroying the file's previous contents. This option is useful
              for collecting information on interactive programs and programs
              that produce output on the standard error stream.
--------------------------------------
and....
--------------------------------------
       -v, --verbose
              Use the built-in verbose format, which displays each available
              piece of information on the program's resource use on its own
              line, with an English description of its meaning.

--------------------------------------
so... I tried calling 'time' first like so: "time -v octave test.m"
which returns:
--------------------------------------
-v: command not found

real 0m0.989s
user 0m0.190s
sys 0m0.070s
--------------------------------------
I also tried the long version:
--------------------------------------
$ time --verbose octave test.m
--verbose: command not found

real 0m0.200s
user 0m0.150s
sys 0m0.060s
--------------------------------------

what??? even the version command doesnt work:

--------------------------------------
$ time --version
--version: command not found

real 0m0.202s
user 0m0.170s
sys 0m0.040s
--------------------------------------

This is a significant issue for my project, since I need to output timing data for a lot of different commands, and I really dont want to copy-paste them all manually from the terminal, and redirecting the error stream (for time's info) isnt an option because I need to collect the program output as well, and it would be significantly difficult to extract the timing data from those files after the fact.

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: time 1.7-23build1
ProcVersionSignature: Ubuntu 2.6.32-25.44-generic 2.6.32.21+drm33.7
Uname: Linux 2.6.32-25-generic x86_64
NonfreeKernelModules: wl
Architecture: amd64
Date: Thu Oct 14 11:51:53 2010
ProcEnviron:
 LANG=en_US.utf8
 SHELL=/bin/bash
SourcePackage: time

Revision history for this message
AFarris01 (afarris01) wrote :
Revision history for this message
Autif Khan (autif-mlist) wrote :

I was able to reproduce the issue with xubuntu 10.04

In fact an adapted example from the man page:

time -a -o log ls -l

does not seem to work

autif@xu:~$ time -a -o log ls -l
-a: command not found

real 0m0.606s
user 0m0.490s
sys 0m0.120s

Changed in time (Ubuntu):
status: New → Confirmed
Revision history for this message
Rohit R (rr0hit) wrote :

None of the options mentioned in the man page seems to work.

I tried --version, --help, --verbose.

None worked.

Revision history for this message
AFarris01 (afarris01) wrote :

ok... I think I figured out why it's doing this, and I'm not sure whether or not to treat this as a bug anymore.

Calling 'time' explicitly (i.e. /usr/bin/time [args]) does actually work properly. For example, calling /usr/bin/time --version yields:
GNU time 1.7

Apparently 'bash' has a built-in command called 'time' that serves a similar purpose, and I didn't see it my first read-through, but the man-page actually mentions this caveat:
-----------------------
 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 still feel this is is an issue, but unless we could disable/override the bash builtin, i don't see how.

Revision history for this message
Kage Jittai (shadowmil) wrote :

Yes this is the issue. Doing:

alias time=/usr/bin/time

Will override bash's default time and use the binary...

Could be added to the default profile or something?

Revision history for this message
Kage Jittai (shadowmil) wrote :

Though we'll also have to add a default formatting. Otherwise the output appears as:

chuck@fate:~$ time echo "Hi"
Hi
0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 2352maxresident)k
0inputs+0outputs (0major+192minor)pagefaults 0swaps

Changed in time (Ubuntu):
status: Confirmed → Opinion
Revision history for this message
Curtis Lee Bolin (curtisleebolin) wrote : Re: [Bug 660655] Re: time command doesnt recognize it's own arguments

Why am I receiving this message?

-Lee

On Fri, Jul 27, 2012 at 1:22 PM, Dmitrijs Ledkovs <email address hidden>wrote:

> ** Changed in: time (Ubuntu)
> Status: Confirmed => Opinion
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/660655
>
> Title:
> time command doesnt recognize it's own arguments
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/time/+bug/660655/+subscriptions
>

Revision history for this message
Hudson Santos (hudsantos) wrote :

Nice ctrl+c and ctrl+v from time man page:

$ time -f "\t%E real,\t%U user,\t%S sys" ls -Fs
-f: command not found

Bug is still there.

Revision history for this message
Hudson Santos (hudsantos) wrote :

It works with full path:

 $ `which time` -f "\t%E real,\t%U user,\t%S sys" ls -Fs

Revision history for this message
Lonnie Lee Best (launchpad-startport) wrote :

This bug was submitted almost a decade ago and it is still an issue on the latest Ubuntu! I guess know one knows where or how to fix it? It seems like it would be a simple thing to fix. What's the problem?

You shouldn't have to type in the full path of a command to pass arguments to it!

Revision history for this message
Lonnie Lee Best (launchpad-startport) wrote :
Revision history for this message
Jeff Lane  (bladernr) wrote :

Still a problem in 20.04. Now its been 5 LTS releases and time is still broken.

Changed in time (Ubuntu):
status: Opinion → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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