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

Re: [PATCH 1/2] CodingGuidelines: Add a note about spaces after redirection

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:09

Tim Henigan [off-list ref] writes:
+ - Redirection operators should be written with space before, but
+   no space after them.  For example:
+      'echo test >$file'  is preferred over
+      'echo test > $file'
+
If you are using a $file placeholder, then we would need to show readers
that they need to be enclosed in dq to prevent some versions of bash from
giving us a false warning, and explicitly say why.

  $ bash
  bash$ file='/var/tmp/f i l e'
  bash$ >$file
  bash: $file: ambiguous redirect
  bash$ >"$file"
  bash$ ls -1 "$file"
  /var/tmp/f i l e

Adding something like this after your two line examples, after updating
them to use "$file" instead, should be sufficient:

	Note that even though it is not required by POSIX to double quote
	the redirection target in a variable like the above example, our
	code does so because some versions of bash issue an warning unless
	we do.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help