CodingGuidelines: give an example for redirection

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2014-04-30 14:24:24 -07:00
parent 79fc3ca123
commit 6a49909b52

View File

@ -61,6 +61,14 @@ For shell scripts specifically (not exhaustive):
redirection target in a variable (as shown above), our code does so redirection target in a variable (as shown above), our code does so
because some versions of bash issue a warning without the quotes. 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 - We prefer $( ... ) for command substitution; unlike ``, it
properly nests. It should have been the way Bourne spelled properly nests. It should have been the way Bourne spelled
it from day one, but unfortunately isn't. it from day one, but unfortunately isn't.