Bug 845925
| Summary: | test -n always returns 0 if evaluating variable | |||
|---|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Martin Kyral <mkyral> | |
| Component: | coreutils | Assignee: | Ondrej Vasik <ovasik> | |
| Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | |
| Severity: | unspecified | Docs Contact: | ||
| Priority: | unspecified | |||
| Version: | 17 | CC: | kdudka, maxamillion, ovasik, p, twaugh | |
| Target Milestone: | --- | |||
| Target Release: | --- | |||
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | Doc Type: | Bug Fix | ||
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 845927 845929 (view as bug list) | Environment: | ||
| Last Closed: | 2012-08-06 07:27:52 UTC | Type: | Bug | |
| Regression: | --- | Mount Type: | --- | |
| Documentation: | --- | CRM: | ||
| Verified Versions: | Category: | --- | ||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
| Cloudforms Team: | --- | Target Upstream Version: | ||
| Embargoed: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 845927, 845929 | |||
|
Description
Martin Kyral
2012-08-06 07:12:52 UTC
Expected results: In step 2, the output is 1 (false in shell semantics). Sorry for the typo.. (In reply to comment #0) > 2. test -n $VAR ; echo $? You need to write: test -n "$VAR" ... so that "test" actually gets an empty string. Otherwise shell will throw the empty string away. Additionally, you are probably using the shell built-in command "test", not the executable /usr/bin/test from coreutils: http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#I-am-having-a-problem-with-kill-nice-pwd-sleep-or-test_002e |