shellcheck
shellcheck copied to clipboard
SC2312: false positive when using 'time'
For bugs
- Rule Id: SC2312
- My shellcheck version: 0.8.0 and online
- [X] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- [X] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
#!/bin/bash
# shellcheck enable=all
set -ex
echo before
time false
echo after
Here's what shellcheck currently says:
[Line 7:](javascript:setPosition(7, 6))
time false
^-- [SC2312](https://www.shellcheck.net/wiki/SC2312) (info): Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).
Here's what I wanted or expected to see:
No warning, as the exit code is not masked. The script will abort if run:
$ ./t.sh || echo 'failed'
+ echo before
before
+ false
real 0m0.000s
user 0m0.000s
sys 0m0.000s
failed