Re: [RFC/PATCH 3/4v2] test-lib: provide lazy TIME_COMMAND prereq
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 16, 2012, 19:34 UTC
- Message-ID
- <7v8vb6rz2n.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <507DB39C.3080005@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
Show 13 quoted lines
> Am 16.10.2012 17:07, schrieb Michael J Gruber: >> Some test want to use the time command (not the shell builtin) and test >> for its availability at /usr/bin/time. >> >> Provide a lazy prereq TIME_COMMAND which tests for $TEST_COMMAND_PATH, >> which can be set from config.mak. It defaults to /usr/bin/time. > > This avoids the builtin: > > command time $that_command > > It works for bash, ksh, zsh, and dash (where the latter doesn't have it > as builtin).
"command time" works but I think that is because it is not a built-in ;-)
Here is what I read in bash(1):
command [-pVv] command [arg ...] Run command with args
suppressing the normal shell function lookup. Only
builtin commands or commands found in the PATH are
executed.Taken together with this from "COMMAND EXECUTION":
If the command name contains no slashes, the shell attempts
to locate it. If there exists a shell function by that name,
that function is invoked as described above in FUNCTIONS. If
the name does not match a function, the shell searches for it
in the list of shell builtins. If a match is found, that
builtin is invoked. If the name is neither a shell function nor a builtin, and
contains no slashes, bash searches each element of the PATH
for a directory containing an executable file by that name.I suspect "command printf 'a b c\n'" would not use $HOME/bin/printf even when I have $HOME/bin early in my $PATH (nor /usr/bin/printf for that matter).