time output does not shows anything
inv2004 opened this issue · 4 comments
Strange… What distribution (and version) are you running this on? What do type time
and which time
output in your /usr/bin/env bash
?
You are right. Looks like it is internal keyword. It is on scaleway and oracle-cloud hostings.
I think it is ubuntu, but very minimal image
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ type time
time is a shell keyword
$ which time
$
$ time ls >/dev/null 2>&1
real 0m0.001s
user 0m0.001s
sys 0m0.000s
$ time | cat
bash: syntax error near unexpected token `|'
I did some investigation and look like the root cause is here: https://en.wikipedia.org/wiki/Time_(Unix)
It also ignores pipeline redirections
and another reason is that I was too lazy to chmod the file and run it simple sh nench.sh
(which is dash) and it caused the problem
I just rechecked it with bash nench.sh
- and it works fine.
Yeah, that would do it. I usually try to keep my scripts within POSIX, but this one definitely requires bash to make the output reformatting less cumbersome.