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

Catch typo with :offset expansion #2048

Open
3 of 4 tasks
dimo414 opened this issue Aug 28, 2020 · 0 comments
Open
3 of 4 tasks

Catch typo with :offset expansion #2048

dimo414 opened this issue Aug 28, 2020 · 0 comments

Comments

@dimo414
Copy link
Contributor

dimo414 commented Aug 28, 2020

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
echo "${1:missing arg}"

Here's what shellcheck currently says:

No issues detected!

Here's what I wanted or expected to see:

I found a typo where I'd intended to write ${1:?missing arg} but left off the ?. This erroneously turns the expansion into an offset expansion, which (AFAICT) silently ignores non-numeric values.

It would be great if ShellCheck could flag usages of ${var:...} where ... isn't a numeral (or a variable).

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
@dimo414 and others