CodingGuidelines: give an example for redirection
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Apr 30, 2014 at 14:24 UTC
6a49909b52b48592234da6a53bfe74ea34c302c6
1 file changed
+8
Documentation/CodingGuidelines
+8
@@ -61,6 +61,14 @@ For shell scripts specifically (not exhaustive):
61
redirection target in a variable (as shown above), our code does so
62
because some versions of bash issue a warning without the quotes.
63
64
+ (incorrect)
65
+ cat hello > world < universe
66
+ echo hello >$world
67
+
68
+ (correct)
69
+ cat hello >world <universe
70
+ echo hello >"$world"
71
+
72
- We prefer $( ... ) for command substitution; unlike ``, it
73
properly nests. It should have been the way Bourne spelled
74
it from day one, but unfortunately isn't.