bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: time keyword evaluates following command's (builtin) argument


From: Greg Wooledge
Subject: Re: time keyword evaluates following command's (builtin) argument
Date: Tue, 16 Jan 2018 08:44:22 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, Jan 16, 2018 at 10:50:34AM +0200, Anti Räis wrote:
> Description:
>     Bash unexpectedly evaluates a builtin command argument when it is
> executed after `time` keyword. This does not happen when the builtin
> command is executed at later time or with different type of argument.

>     alias exp='"$($1)"'
>     echo exp
>     time
>     echo exp
>     echo exp

Hmm, there is certainly something weird going on here.  I can reproduce
this in Debian's 4.4.  It has something to do with alias expansions,
and failing to provide a command on a 'time' command (which is quite a
bizarre thing to do).

wooledg:~$ cat x
#!/bin/bash
shopt -s expand_aliases
alias x=date
echo x 1
time
echo x 2
time :
echo x 3

wooledg:~$ ./x
x 1
real 0.000  user 0.000  sys 0.000
date 2
real 0.000  user 0.000  sys 0.000
x 3

As long as I provide a command to 'time', all is fine.  I get the same
results in an interactive shell.

wooledg:~$ cat /etc/debian_version 
9.3
wooledg:~$ dpkg -l bash | tail -1
ii  bash           4.4-5        amd64        GNU Bourne Again SHell
wooledg:~$ echo "$BASH_VERSION"
4.4.12(1)-release
wooledg:~$ declare -p TIMEFORMAT
declare -x TIMEFORMAT="real %R  user %U  sys %S"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]