Questions tagged [shellcheck]

shellcheck is a tool for automatically detecting shell script problems

Filter by
Sorted by
Tagged with
2
votes
1answer
48 views

Why I have to not quote a string variable in this specific case?

My Ubuntu/Debian-based Linux update POSIX shell script seems to require me not to double quote the string variable with the stored command, which is being executed. As I don't understand this issue, I'...
0
votes
0answers
20 views

Why does running shellcheck from the demo flatpak work, but fail in Atom?

I've installed Atom from flathub. Now using the linter-shellcheck fails and says, the shellcheck command is not available. However, if I use the flatpak demo application and use flatpak enter to ...
5
votes
1answer
304 views

Bash: What does “masking return values” mean?

shellcheck generated the following warning SC2155: Declare and assign separately to avoid masking return values For this line of code local key_value=$(echo "$current_line" | mawk '/.+=.+/ {print $...
1
vote
1answer
135 views

Define variable using read from stdin of heredoc

I am trying to store Available and Total Memory into variables in a script file as follows, read -r Available Total <<EOT $(free -m | awk '/^Mem/{print $7; print $2;}') EOT $ echo $Total $ ...
6
votes
1answer
229 views

Unexpected outcome of a=“$@”

I'm struggling with this situation: $ set -- 1 2 3 $ a="$@" $ echo "$a" 1 2 3 What I find unexpected is the assignment itself. man bash says this about the "$@" expansion: When the expansion ...
1
vote
1answer
69 views

printf work-alike wrapper for prefixing and redirecting error messages

I have an error function in my POSIX sh shell code. It essentially looks like error () { printf 'utility: ERROR: ' >&2 printf "$@" >&2 } The second printf makes it so that I ...
3
votes
2answers
390 views

shellcheck warns about loops over find output even when given the path to begin search [duplicate]

Ubuntu 16.04 #!/bin/bash site="hello" wDir="/home/websites/${site}/httpdocs/" for file in $(find "${wDir}" -name "*.css") do echo "$file"; done exit 0; shellcheck warns me even if I define the ...
-3
votes
3answers
773 views

“Make sure not to read and write the same file in the same pipeline” [duplicate]

shellcheck reports: echo -e "blah/blah\n$(cat "$tmpdir"/"$filename".jpdf)" > "$tmpdir"/"$filename".jpdf ^-- SC2094: Make sure not to read and write the same file in the ...
3
votes
2answers
142 views

Shellcheck complains that I should not to read and write the same file in the same pipeline

ShellCheck show the following error for this line of code: printf '%d' $(($(< "$1") + 1)) > "$1" Make sure not to read and write the same file in the same pipeline Is this really a problem? ...
7
votes
1answer
506 views

bash shellcheck issue with variables in brace expansion

I'm trying to create an array of file names, based on two variable and using brace expansion, like this: #!/bin/bash altdir=/usr arg=abc tries=({.,$altdir}/{$arg,$arg/main}.{tex,ltx,drv,dtx}) for i ...