mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Updated SC2202 (markdown)
@@ -4,7 +4,6 @@
|
||||
|
||||
```sh
|
||||
[ current.log -nt backup/*.log ] && echo "This is the latest file"
|
||||
|
||||
```
|
||||
|
||||
### Correct code:
|
||||
@@ -30,7 +29,7 @@ Instead, use a `for` loop to iterate over matching filenames, and apply your con
|
||||
|
||||
If you know your glob will only ever match one file, you can check this explicitly and use the first file:
|
||||
|
||||
```
|
||||
```sh
|
||||
set -- backup/*.log
|
||||
[ $# -eq 1 ] || { echo "There are too many matches."; exit 1; }
|
||||
[ file.log -nt "$1" ] && echo "This is the latest file"
|
||||
|
Reference in New Issue
Block a user