From 38c0dccb210d598ef5747136665f544d2116600a Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 19 Apr 2014 11:59:43 -0700 Subject: [PATCH] Created SC2129 (markdown) --- SC2129.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 SC2129.md diff --git a/SC2129.md b/SC2129.md new file mode 100644 index 0000000..6183038 --- /dev/null +++ b/SC2129.md @@ -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. \ No newline at end of file