mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Created SC2129 (markdown)
24
SC2129.md
Normal file
24
SC2129.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## Consider using { cmd1; cmd2; } >> file instead of individual redirects.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
echo foo >> file
|
||||
date >> file
|
||||
cat stuff >> file
|
||||
|
||||
|
||||
### Correct code:
|
||||
|
||||
{
|
||||
echo foo
|
||||
date
|
||||
cat stuff
|
||||
} >> file
|
||||
|
||||
### Rationale:
|
||||
|
||||
Rather than adding `>> something` after every single line, you can simply group the relevant commands and redirect the group.
|
||||
|
||||
### Contraindications
|
||||
|
||||
This is mainly a stylistic issue, and can freely be ignored.
|
Reference in New Issue
Block a user