Bug 1005900 - Built-in time command cannot be executed when the command is expanded from a variable
Summary: Built-in time command cannot be executed when the command is expanded from a ...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Roman Rakus
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-09 15:58 UTC by Petr Pisar
Modified: 2014-01-13 00:15 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-10 12:37:34 UTC
Type: Bug


Attachments (Terms of Use)

Description Petr Pisar 2013-09-09 15:58:42 UTC
I have a very strange problem. I cannot execute `time' built-in command if the command is resolution of variable expansion:

root@fedora-21:~ # cat /tmp/expandedtime 
#!/bin/bash
set -x
VARIABLE="time"
"$VARIABLE" /bin/true
root@fedora-21:~ # /tmp/expandedtime 
+ VARIABLE=time
+ time /bin/true
/tmp/expandedtime: line 4: time: command not found
root@fedora-21:~ # time /bin/true

real    0m0.006s
user    0m0.002s
sys     0m0.004s
root@fedora-21:~ # type -a time
time is a shell keyword
root@fedora-21:~ # rpm -qf /bin/bash
bash-4.2.45-4.fc20.x86_64

I observe this problem in Fedora 21, and 20. I cannot reproduce it in Fedora 19. However my colleague has similar problem even in Fedora 19. Everything on x86_64. If I replace the `time' for some other built-in, like `help', the bug disappears.

Comment 1 Petr Pisar 2013-09-09 16:03:51 UTC
So I can reproduce it even in Fedora 19. If /usr/bin/time (from standalone `time' package) is installed, the script can execute time built-in. If I uninstall the package, it is not possible to execute the built-in.

Comment 2 Roman Rakus 2013-09-10 12:37:34 UTC
(In reply to Petr Pisar from comment #1)
> So I can reproduce it even in Fedora 19. If /usr/bin/time (from standalone
> `time' package) is installed, the script can execute time built-in. If I
> uninstall the package, it is not possible to execute the built-in.

time is not builtin. The same result is with `while' for example.

Comment 3 Petr Pisar 2013-09-10 12:59:22 UTC
I see. So that's the difference between built-in command and keyword.


Note You need to log in before you can comment on or make changes to this bug.