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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim Henigan <tim.henigan@xxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]