bug-coreutils
[Top][All Lists]
Advanced

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

bug#72756: Potential Bug/Vuln in test.c


From: Thomas Wolff
Subject: bug#72756: Potential Bug/Vuln in test.c
Date: Thu, 22 Aug 2024 09:29:28 +0200
User-agent: Mozilla Thunderbird


Am 22.08.2024 um 08:54 schrieb Philip Rowlands:
On Wed, 21 Aug 2024, at 18:29, Nathan Hays via GNU coreutils Bug Reports wrote:
Test:
~~~bash
testvar=''
[ -n $testvar ]
echo -n unquote exit $?
[ -n "$testvar" ]
echo -n quote exit $?
[ -z $testvar ]
echo -z unquote exit $?
[ -z "$testvar" ]
echo -z quote exit $?
~~~
For this code snippet, the shellcheck linter reports

[ -n $testvar ]
      ^------^ SC2070: -n doesn't work with unquoted arguments. Quote or use [[ 
]].
      ^------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
[ -n "$testvar" ]

For more information:
   https://www.shellcheck.net/wiki/SC2070  -- -n doesn't work with unquoted 
arg...
It's a similar confusing syntax glitch as in shell:
# cond=true # commented out with the assumption the below condition will
not be true then
if $cond
then echo surprise # but it is
fi

Cheers
Thomas

Cheers,
Phil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]