Thread (1 message) 1 message, 1 author, 2016-06-15
DORMANTno replies

[PATCH v2 3/8] CodingGuidelines: give an example for redirection

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:00:57
Subsystem: documentation, the rest · Maintainers: Jonathan Corbet, Linus Torvalds

Signed-off-by: Junio C Hamano <redacted>
---

 * Instead of using trailing "# correct" comment on each of the
   one-liners, group the good ones and the bad ones into two groups
   and give (incorrect)/(correct) header like the other patches as
   suggested.  How does this look?

   The only reason I originally did these differently is because
   these are two independent examples, and I thought it would make
   the difference stand out better to the readers if we showed
   good/bad pairs of "cat" and "echo" that way.  But as long as we
   are not going to add more examples here, I think the result is
   not too bad.

 Documentation/CodingGuidelines | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 6a8e94b..6bfe96e 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -61,6 +61,14 @@ For shell scripts specifically (not exhaustive):
    redirection target in a variable (as shown above), our code does so
    because some versions of bash issue a warning without the quotes.
 
+	(incorrect)
+	cat hello > world < universe
+	echo hello >$world
+
+	(correct)
+	cat hello >world <universe
+	echo hello >"$world"
+
  - We prefer $( ... ) for command substitution; unlike ``, it
    properly nests.  It should have been the way Bourne spelled
    it from day one, but unfortunately isn't.
-- 
2.0.0-rc1-355-gd6d6511
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help