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

[Cheat sheet] Update shellcheck #335

Open
coolaj86 opened this issue Nov 18, 2021 · 2 comments
Open

[Cheat sheet] Update shellcheck #335

coolaj86 opened this issue Nov 18, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers hacktoberfest up-for-grabs

Comments

@coolaj86
Copy link
Member

coolaj86 commented Nov 18, 2021

I'm gonna add the error codes that I disable the most often to the cheat sheet:

SC1004 This backslash+linefeed is literal. Break outside single quotes if you just want to break the line.
# for source .env, etc
SC1091 Not following: (error message here)
SC2001 See if you can use ${variable//search/replace} instead.
SC2016 Expressions don't expand in single quotes, use double quotes for that.
SC2029 Note that, unescaped, this expands on the client side.
SC2034 foo appears unused. Verify it or export it.
SC2072 Decimals are not supported. Either use integers only, or use bc or awk to compare.
SC2086 Double quote to prevent globbing and word splitting.
SC2087 Quote 'EOF' to make here document expansions happen on the server side rather than on the client.
SC2088 Tilde does not expand in quotes. Use $HOME.
SC2129 Consider using { cmd1; cmd2; } >> file instead of individual redirects.
SC2155 Declare and assign separately to avoid masking return values.
shellcheck disable=SC2207,SC2053,SC1083,SC1091,SC2129,SC2155
@coolaj86
Copy link
Member Author

This is partially negated by #656

@coolaj86 coolaj86 added documentation Improvements or additions to documentation good first issue Good for newcomers up-for-grabs hacktoberfest labels Oct 17, 2023
@y0rune
Copy link
Collaborator

y0rune commented Mar 10, 2024

Would you like to create a cheatsheet with all using SC disable at files?
If yes I created a one line for that, using a documentation about ShellCheck:

yorune@Hana ~/git/webi-installers main $ shellcheck_gist=$(curl --silent https://gist.githubusercontent.com/nicerobot/53cee11ee0abbdc997661e65b348f375/raw/d5a97b3b18ead38f323593532050f0711084acf1/_shellcheck.md); for i in $(grep --color=no -hroE 'SC[0-9]+' | sort -u | grep SC); do echo -e "$i $(echo $shellcheck_gist | grep $i | sed 's/\[SC.*) //g' )"; done
SC1003 - Want to escape a single quote? echo 'This is how it'\''s done'.
SC1004 - This backslash+linefeed is literal. Break outside single quotes if you just want to break the line.
SC1090 - Can't follow non-constant source. Use a directive to specify location.
SC2005 - Useless `echo`? Instead of `echo $(cmd)`, just use `cmd`
SC2010 - Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.
SC2016 - Expressions don't expand in single quotes, use double quotes for that.
SC2030 - Modification of var is local (to subshell caused by pipeline).
SC2034 - foo appears unused. Verify it or export it.
SC2046 - Quote this to prevent word splitting
SC2059 - Don't use variables in the printf format string. Use printf "..%s.." "$foo".
SC2086 - Double quote to prevent globbing and word splitting.
SC2088 - Tilde does not expand in quotes. Use $HOME.
SC2154 - var is referenced but not assigned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers hacktoberfest up-for-grabs
Projects
None yet
Development

No branches or pull requests

2 participants