Re: [PATCH resend] properly quote strings tested with -n

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



On Wed, Oct 14, 2015 at 08:22:37AM -0500, Eric Sandeen wrote:
> Per the Advanced Bash Scripting Guide:
> 
> "The -n test requires that the string be quoted within the test brackets.
> Using an unquoted string with ! -z, or even just the unquoted string
> alone within test bracket normally works, however, this is an unsafe
> practice. Always quote a tested string."
> 
> And indeed:
> 
> $ unset FOOBAR
> $ [ -n $FOOBAR ] || echo nope
> $ [ -n "$FOOBAR" ] || echo nope
> nope
> 
> Ran into this on a box w/o the attr program installed, and passed
> _require_attrs.  Quoting the string fixes this; fix it there
> and other occurrences in common/* as well.
> 
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> Reviewed-by: Alex Elder <elder@xxxxxxxxxx>

A quick search shows that all strings after "[ -n " are quoted after
applying this patch.

Reviewed-by: Eryu Guan <eguan@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux