From 33453208495b1c84d05dacd155c9d5174f299d11 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 19 Mar 2016 16:56:51 -0700 Subject: [PATCH] Created SC2177 (markdown) --- SC2177.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 SC2177.md diff --git a/SC2177.md b/SC2177.md new file mode 100644 index 0000000..9070f2f --- /dev/null +++ b/SC2177.md @@ -0,0 +1,20 @@ +## 'time' is undefined for compound commands, time sh -c instead. + +### Problematic code: + +```sh +time for i in *.bmp; do convert "$i" "$i.png"; done +``` + +### Correct code: + +```sh +time sh -c 'for i in *.bmp; do convert "$i" "$i.png"; done' +``` +### Rationale: + +`time` is only defined for Simple Commands [by POSIX](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/time.html). Timing loops, command groups and similar is not. + +### Exceptions: + +None. If you use a shell that supports this (e.g. bash, ksh), specify this shell in the shebang. \ No newline at end of file