Skip to content

Commit 48f359b

Browse files
thenigangitster
authored andcommitted
CodingGuidelines: Add a note about spaces after redirection
During code review of some patches, it was noted that redirection operators should have space before, but no space after them. Signed-off-by: Tim Henigan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 64baa41 commit 48f359b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Documentation/CodingGuidelines

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ For shell scripts specifically (not exhaustive):
3535

3636
- Case arms are indented at the same depth as case and esac lines.
3737

38+
- Redirection operators should be written with space before, but no
39+
space after them. In other words, write 'echo test >"$file"'
40+
instead of 'echo test> $file' or 'echo test > $file'. Note that
41+
even though it is not required by POSIX to double-quote the
42+
redirection target in a variable (as shown above), our code does so
43+
because some versions of bash issue a warning without the quotes.
44+
3845
- We prefer $( ... ) for command substitution; unlike ``, it
3946
properly nests. It should have been the way Bourne spelled
4047
it from day one, but unfortunately isn't.

0 commit comments

Comments
 (0)