Unix Programming - what shell does 'time' use?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > what shell does 'time' use?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author what shell does 'time' use?
Norm Dresner

2004-01-23, 4:57 pm

I attempted to use the standard utility time to find out how long a
particular command took. But I used an alias for it and it was apparently
not known within the "shell" that time invoked. Would I need to explicitly
include a shell invocation along with the command to get aliases?
FWIW, IRIX 6.5.20

TIA
Norm


=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-23, 4:57 pm

"Norm Dresner" <ndrez@att.net> writes:
quote:

> I attempted to use the standard utility time to find out how long a
> particular command took. But I used an alias for it and it was apparently
> not known within the "shell" that time invoked. Would I need to explicitly
> include a shell invocation along with the command to get aliases?



Which shell are you using? Both bash and tcsh have builtin time
commands. If you are using an external time command, chances are that
it invokes either /bin/sh, or $SHELL. Whichever it uses, it's likely
that whatever startup files it uses, are not processed, so any aliases
set there might not be available.

--
Måns Rullgård
mru@kth.se
Michael Fuhr

2004-01-23, 4:57 pm

mru@kth.se (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=) writes:
quote:

> "Norm Dresner" <ndrez@att.net> writes:
>
>
> Which shell are you using? Both bash and tcsh have builtin time
> commands. If you are using an external time command, chances are that
> it invokes either /bin/sh, or $SHELL. Whichever it uses, it's likely
> that whatever startup files it uses, are not processed, so any aliases
> set there might not be available.



External time commands (often /usr/bin/time) typically call execvp()
or one of its friends to run the command directly; they don't usually
run it via a shell. If you want to use an external time command
to time an alias or a shell builtin then you'll have to invoke the
shell and dance whatever dance is required to have it run the
command. This is typically done with the -c option, although the
shell might not read startup files when run with this option, which
means aliases might not be defined. You'll have to read your shell's
documentation and play with it to see what works.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Norm Dresner

2004-01-23, 4:58 pm

"Måns Rullgård" <mru@kth.se> wrote in message
news:yw1x8ymystif.fsf@kth.se...
quote:

> "Norm Dresner" <ndrez@att.net> writes:
>
apparently[QUOTE][color=darkred]
explicitly[QUOTE][color=darkred]
>
> Which shell are you using? Both bash and tcsh have builtin time
> commands. If you are using an external time command, chances are that
> it invokes either /bin/sh, or $SHELL. Whichever it uses, it's likely
> that whatever startup files it uses, are not processed, so any aliases
> set there might not be available.



It was in the tcsh. I just tried running
time alias
and it appears that all of my normal aliases are there. Since the system
has been rebooted twice since the problem occurred, I'll probably never know
what happened. Thanks for a response.

Norm


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com