Comments (15)
It's per structure, so you can do
shellcheck disable=SC2034
{
AAAA=aaaa
BBBB=bbbb
CCCC=cccc
DDDD=dddd
}
from shellcheck.
I actually don't want to disable this warning for all files I'm checking, just specific ones.
from shellcheck.
I would find this feature useful
from shellcheck.
From 43ed5e7 you can use # shellcheck disable=SC1234,SC5678
. It's scoped to the immediate pipeline and any &&/|| following it.
It's worth noting that errors in a shellcheck directive (# shellcheck...
) is a parsing error by design. This lets shellcheck tell you why # shellcheck ignore=1234:5678
is wrong, but also means that parsing stops if you've written # shellcheck doesn't like this
.
I'd appreciate any feedback people have for this feature!
from shellcheck.
How can I disable the ps|grep warning here:
echo -n " zombie: $(ps -e -o state | grep Z | wc -l) "
from shellcheck.
# shellcheck disable=SC2009
echo -n " zombie: $(ps -e -o state | grep Z | wc -l) "
from shellcheck.
Thank you, I made a a dumb error: I had typo in the warning id, that's why it seemed not to work.
from shellcheck.
feedback is that it works great. maybe add it to the --help docs for ease of use?
from shellcheck.
It appears the directive will only apply to the line following the directive. For example:
# shellcheck disable=SC2034
AAAA=aaaa # < No 'appears unused'
BBBB=bbbb # < Getting 'appears unused' error
# shellcheck disable=SC2034
CCCC=cccc # < No 'appears unused'
DDDD=dddd # < Getting 'appears unused' error
I would expect the shellcheck directive to disable all of this error in the file, but if we need backwards compatibility, I would like a way to disable all of a specific type of error for the whole file.
My usecase: I have a dotenv
file where I am declaring a lot of variables that I'm never using, because they are getting used in other files in my application. I would like to use shellcheck
to syntax check the file but I don't need any 'appears unused' errors as they are irrelevant to my use.
I would strongly prefer not to have to write a shellcheck disable
for each line in my file...
from shellcheck.
I used that method to solve my problem and it did work in my case, however I dislike the idea of having to change my code structure in order to make an ignore rule function. I would prefer to see a different directive to make all instances ignored.
Thanks for the feature though, it works great otherwise and this linter is very helpful for showing me some best-practices that I didn't know about.
from shellcheck.
Thanks, glad you like it!
In the near future you're likely to see file-wide ignores, but right now they're per structure
from shellcheck.
Understood. Thanks.
from shellcheck.
@servel333 also remember that you can disable it on the command line, might hide valid warnings in other files if you are processing more than one in a single go though. Just mentioning it as it looks like it's missing in this thread.
brother ~$ cat /tmp/test.sh
#!/bin/sh
echo "--no quote--"
for i in ${TMPDIR:=/tmp}; do echo "$i"; done
echo "------------"
echo "--- quote---"
for i in "${TMPDIR:=/tmp}"; do echo "$i"; done
echo "------------"
# shellcheck disable=SC2034
AAAA=aaaa # < No 'appears unused'
BBBB=bbbb # < Getting 'appears unused' error
# shellcheck disable=SC2034
CCCC=cccc # < No 'appears unused'
DDDD=dddd # < Getting 'appears unused' error
brother ~$ shellcheck /tmp/test.sh
In /tmp/test.sh line 8:
for i in "${TMPDIR:=/tmp}"; do echo "$i"; done
^-- SC2066: Since you double quoted this, it will not word split, and the loop will only run once.
In /tmp/test.sh line 13:
BBBB=bbbb # < Getting 'appears unused' error
^-- SC2034: BBBB appears unused. Verify it or export it.
In /tmp/test.sh line 16:
DDDD=dddd # < Getting 'appears unused' error
^-- SC2034: DDDD appears unused. Verify it or export it.
brother ~$ shellcheck /tmp/test.sh -eSC2034
In /tmp/test.sh line 8:
for i in "${TMPDIR:=/tmp}"; do echo "$i"; done
^-- SC2066: Since you double quoted this, it will not word split, and the loop will only run once.
from shellcheck.
I didn't know you could disable it in the command line like that. I'm using Sublime that's auto-running the command though and so for my use case it doesn't solve my problem. Good to know though, thanks.
from shellcheck.
If Sublime isn't configurable you can set SHELLCHECK_OPTS in recent versions of shellcheck
from shellcheck.
Related Issues (20)
- Coalesce quotes with `shellcheck -p diff`
- Report spam in the wiki HOT 2
- Busybox sh and glob matching HOT 1
- ksh: Unexpected failure when using functions in arithmetic expressions
- SC1091 after checking that file exists HOT 1
- Wrong format string variables count
- shellcheck fails to parse tests when the comparator is a variable.
- SC2164 HOT 2
- Associative array assignment with quoted keys triggers SC2079 HOT 1
- Writeable directory test passes with undefined variable HOT 6
- SC2206: Exception for integer variables HOT 1
- Feature Request: Partial runtime validator backed by Morbig for POSIX shell
- SC2006 triggered with quotes and backtics misinterpreted
- Shellcheck does not work with big shellscript file, appears to hang?
- QuickCheck-2.15 not accepted
- Disable directive ignored in array?
- shellcheck.net HTTPS certificate expired HOT 3
- Drop support for some really old GHC versions
- Add a reason directive to document why some checks were disabled HOT 1
- ksh `set -A` not recognized as an assignment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shellcheck.