Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO: Add title #1722

Closed
3 of 4 tasks
chepner opened this issue Oct 18, 2019 · 1 comment
Closed
3 of 4 tasks

TODO: Add title #1722

chepner opened this issue Oct 18, 2019 · 1 comment

Comments

@chepner
Copy link

chepner commented Oct 18, 2019

For bugs

  • Rule Id (if any, e.g. SC1000):
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/bash

a=

if [ -z $a ]; then echo pass; fi

Here's what shellcheck currently says:


Here's what I wanted or expected to see:

The lack of a warning here (even though [ -z ] and [ -z "" ] have the same results, though for different reasons) feels inconsistent. I acknowledge that a warning is raised when the value of a cannot be statically determined.

@koalaman
Copy link
Owner

koalaman commented Nov 3, 2019

Wow, great catch. ShellCheck just checked whether the variable might contain spaces, which an empty variable obviously can't. This check will now additionally track whether the variable may be empty, so that this warning will still trigger. Thanks!

Kangie pushed a commit to Kangie/shellcheck that referenced this issue Feb 27, 2023
Merge of upstream through 5c7d812

Conflicts:
	src/ShellCheck/Analytics.hs

Manual changes:
        Cleaned up mintor conflicts in variables with spaces lists.

Changelog:
----------------------------------------------------------------
Benjamin Gordon (12):
      CHROMIUM: Exclude from CQ
      CHROMIUM: Initial support for portage
      CHROMIUM: Disable SC2155 for portage files
      CHROMIUM: Make SC2164 recommend die when running in portage
      CHROMIUM: Add predefined portage variables
      CHROMIUM: Add OWNERS file
      CHROMIUM: Add eclass variables to portage lists
      CHROMIUM: Don't warn about missing find paths in portage
      CHROMIUM: Add more internal portage variables
      CHROMIUM: Disable SC2016 for python_gen_any_dep
      CHROMIUM: Exempt more commands from single quote warnings
      SC2256: Check for translated strings matching known variables

David Burger (1):
      Remove binhost-pre-cq from COMMIT-QUEUE.ini.

Laurent VERDOÏA (1):
      Make image build process a bit simpler

Merlin Göttlinger (1):
      Nix install instructions

Supanat Pothivarakorn (1):
      Allow `read -t 0` to not require -r flag

Vidar Holen (29):
      Make `-f diff` stop saying it found more issues when it didn't.
      Update TravisCI config for new winghc docker image
      Remove _cleanup now that builds don't run in sequence
      Suggest quoting case patterns, as for SC2053 (fixes koalaman#1682)
      Fix glob range duplicate warning in [!!] (fixes koalaman#1706)
      Suggest using `$((..))` in `[ 2*3 -eq 6 ]` (fixes koalaman#1641)
      Merge branch 'read-t-0' of https://github.com/iboss-ptk/shellcheck into iboss-ptk-read-t-0
      Make `read -t 0` test more forgiving towards other flags
      Move failing test to correct check
      Merge branch 'iboss-ptk-read-t-0'
      Warn about unexpected characters after ]/]] (fixes koalaman#1680)
      Use single quotes for the format string example in SC2059
      Correctly handle empty variables for SC2086 (fixes koalaman#1722)
      Warn about [ x -ot y ] in POSIX mode
      Only trigger SC1014 when command is a complete word (fixes koalaman#1737)
      For SC2256, make sure the complete string is a variable name
      Merge branch 'translatedVars'
      Merge pull request koalaman#1749 from lvjp/simple-docker-build
      Include missing Semigroup import
      Hide <> from Writer to not conflict with Semigroup
      Update brew before building on macOS due to incompatible Ruby
      Merge pull request koalaman#1735 from gabrielelana/quoted-heredoc
      Merge pull request koalaman#1734 from gabrielelana/braced-regular-for
      Merge pull request koalaman#1716 from ryantig/ryantig-patch-1
      Merge pull request koalaman#1728 from mgttlinger/patch-1
      Support Cabal 3. Man page no longer autobuilds.
      Explicitly add 'mappend' for old GHC versions
      Revert docker image to 18.04 since ld fails on later versions
      Try to search for binary on macOS/Cabal3

Will Bradley (5):
      Allow local in sh scripts even though it isn't officially part of POSIX shell.
      CHROMIUM: stop complaining about 'which' in portage build scripts
      CHROMIUM: portage compatibility: squelch warnings for EBUILD_PHASE_FUNC
      CHROMIUM: increase depth of categorization for Portage files
      CHROMIUM: Implement check for illegal stable KEYWORDS in -9999 cros-workon Ebuilds.

gabriele.lana (2):
      Parse regular `for` with body in curly braces
      Support for heredoc quoted token like `'"FOO"`

ryantig (1):
      Update README.md

 .compile_binaries                     |  23 +-
 .travis.yml                           |   2 +-
 CHANGELOG.md                          |  11 +
 COMMIT-QUEUE.ini                      |  12 +
 Dockerfile                            |   4 +-
 OWNERS                                |   3 +
 README.md                             |   7 +-
 Setup.hs                              |  36 --
 ShellCheck.cabal                      |  12 +-
 manpage                               |   4 +
 shellcheck.1.md                       |   5 +-
 src/ShellCheck/AST.hs                 |   2 +-
 src/ShellCheck/Analytics.hs           | 222 ++++++++++--
 src/ShellCheck/AnalyzerLib.hs         |  38 ++-
 src/ShellCheck/Checker.hs             |   7 +-
 src/ShellCheck/Checks/Commands.hs     |  37 +-
 src/ShellCheck/Checks/ShellSupport.hs |   4 +-
 src/ShellCheck/Data.hs                | 625 +++++++++++++++++++++++++++++++++-
 src/ShellCheck/Formatter/Diff.hs      |  21 +-
 src/ShellCheck/Interface.hs           |  24 +-
 src/ShellCheck/Parser.hs              |  26 +-
 21 files changed, 978 insertions(+), 147 deletions(-)
 create mode 100644 COMMIT-QUEUE.ini
 create mode 100644 OWNERS
 delete mode 100644 Setup.hs
 create mode 100755 manpage

BUG=chromium:1024635
TEST=stack test

Change-Id: I3eb00707cb2f2b4e967d4db430a7e8ca2e41626e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants