diff --git a/it/Dockerfile-auditor b/it/Dockerfile-auditor
index fd17dfa..e969c74 100644
--- a/it/Dockerfile-auditor
+++ b/it/Dockerfile-auditor
@@ -1,4 +1,38 @@
-ARG JDK_VERSION=8
-FROM openjdk:${JDK_VERSION}
-COPY it /usr/src/myapp/it
+ARG SCANNER_VERSION=latest
+FROM sonarsource/sonar-scanner-cli:${SCANNER_VERSION} AS builder
+
+FROM eclipse-temurin:21-jre-alpine
+
+ARG SONAR_SCANNER_HOME=/opt/sonar-scanner
+ENV HOME=/tmp \
+ SONAR_SCANNER_HOME=${SONAR_SCANNER_HOME} \
+ XDG_CONFIG_HOME=/tmp \
+ SONAR_USER_HOME=${SONAR_SCANNER_HOME}/.sonar \
+ PATH=${SONAR_SCANNER_HOME}/bin:${PATH} \
+ SRC_PATH=/usr/src \
+ SCANNER_WORKDIR_PATH=/tmp/.scannerwork \
+ LANG=C.UTF-8 \
+ LC_ALL=C.UTF-8 \
+ PYTHONUNBUFFERED=1
+
WORKDIR /usr/src/myapp/it
+
+USER root
+# Copy Scanner installation from builder image
+COPY --from=builder /opt/sonar-scanner /opt/sonar-scanner
+
+
+RUN apk update --no-cache && \
+ apk add --update --no-cache -q curl gcc jq libffi-dev musl-dev openssl-dev python3 py3-requests shellcheck
+
+RUN set -eux && \
+ addgroup --gid 1000 scanner-cli && \
+ adduser --uid 1000 --ingroup scanner-cli --disabled-password --no-create-home --gecos "" scanner-cli && \
+ chown -R scanner-cli:scanner-cli "${SONAR_SCANNER_HOME}" "${SRC_PATH}" && \
+ mkdir -p "${SRC_PATH}" "${SONAR_USER_HOME}" "${SONAR_USER_HOME}/cache" "${SCANNER_WORKDIR_PATH}" && \
+ chown -R scanner-cli:scanner-cli "${SONAR_SCANNER_HOME}" "${SRC_PATH}" "${SCANNER_WORKDIR_PATH}" && \
+ chmod -R 555 "${SONAR_SCANNER_HOME}" && \
+ chmod -R 754 "${SRC_PATH}" "${SONAR_USER_HOME}" "${SCANNER_WORKDIR_PATH}"
+
+USER scanner-cli
+COPY it /usr/src/myapp/it
diff --git a/it/audit.sh b/it/audit.sh
index 06bac8e..43cac0b 100644
--- a/it/audit.sh
+++ b/it/audit.sh
@@ -1,26 +1,12 @@
-#!/bin/bash -e
-
-# Install requirements
-echo "Installing ShellCheck..."
-if grep -q Debian /etc/issue
-then
- apt-get -qq update
- apt-get -qq install -y shellcheck > /dev/null
-else
- apk update
- apk add -q shellcheck
-fi
-
-# Install sonar-runner
-echo "Installing Sonar scanner..."
-cd /tmp
-wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SCANNER_VERSION.zip
-unzip -q sonar-scanner-cli-$SCANNER_VERSION.zip
-export PATH=/tmp/sonar-scanner-$SCANNER_VERSION/bin:$PATH
+#!/bin/sh -e
# Configure sonar-runner
-echo "sonar.host.url=http://sonarqube:9000" > /tmp/sonar-scanner-$SCANNER_VERSION/conf/sonar-scanner.properties
+export SONAR_HOST_URL="http://sonarqube:9000"
+# Generate Analysis token
+echo "Generating analysis token..."
+export SONAR_TOKEN=$(curl -su "admin:admin" -XPOST "$SONAR_HOST_URL/api/user_tokens/generate?name=analysis_token&type=GLOBAL_ANALYSIS_TOKEN" | jq -r '.token')
+echo $SONAR_TOKEN
# Audit code
echo "Launching scanner..."
cd /usr/src/myapp/it
@@ -43,20 +29,14 @@ sleep 10
# Check audit result
echo "Checking result..."
-if grep -q Debian /etc/issue
-then
- apt-get -qq install -y python3-pip > /dev/null
-else
- apk add -q curl gcc musl-dev libffi-dev openssl-dev py3 py3-dev
-fi
-pip3 install -q requests
python3 << EOF
from __future__ import print_function
import requests
import sys
-r = requests.get('http://sonarqube:9000/api/measures/component?component=my:project&metricKeys=ncloc,comment_lines,lines,files,directories,violations', auth=('admin', 'admin'))
+r = requests.get('http://sonarqube:9000/api/measures/component?component=my:project&metricKeys=ncloc,comment_lines,lines,files,violations', auth=('admin', 'admin'))
if r.status_code != 200:
+ print('Invalid server response: ' + str(r.status_code), file=sys.stderr)
sys.exit(1)
data = r.json()
@@ -70,20 +50,15 @@ for measure in data['component']['measures']:
if measure['metric'] == 'lines' and measure['value'] == '8':
print('lines metrics OK')
lines = True
-# if measure['metric'] == 'ncloc' and measure['value'] == '87':
-# print('ncloc metrics OK')
-# ncloc = True
- ncloc = True
+ if measure['metric'] == 'ncloc' and measure['value'] == '3':
+ print('ncloc metrics OK')
+ ncloc = True
if measure['metric'] == 'files' and measure['value'] == '1':
print('files metrics OK')
files = True
- if measure['metric'] == 'directories' and measure['value'] == '1':
- print('directories metrics OK')
- directories = True
-# if measure['metric'] == 'comment_lines' and measure['value'] == '1':
-# print('comment_lines metrics OK')
-# comment_lines = True
- comment_lines = True
+ if measure['metric'] == 'comment_lines' and measure['value'] == '1':
+ print('comment_lines metrics OK')
+ comment_lines = True
if measure['metric'] == 'violations' and measure['value'] == '3':
print('violations metrics OK')
violations = True
diff --git a/it/docker-compose.yml b/it/docker-compose.yml
index fa0b117..c7d3785 100644
--- a/it/docker-compose.yml
+++ b/it/docker-compose.yml
@@ -1,8 +1,7 @@
---
-version: '2.2'
services:
sonarqube:
- image: sonarqube:${SONARQUBE_VERSION:-6.6}
+ image: sonarqube:${SONARQUBE_VERSION:-community}
ports:
- "9000:9000"
environment:
@@ -10,14 +9,14 @@ services:
security_opt:
- seccomp:unconfined
auditor:
- image: auditor:${SCANNER_VERSION}-jdk${JAVA_VERSION:-8}
+ image: auditor:${SCANNER_VERSION:-latest}
build:
context: ..
dockerfile: it/Dockerfile-auditor
args:
- JDK_VERSION: ${JAVA_VERSION:-8}
+ SCANNER_VERSION: ${SCANNER_VERSION:-latest}
links:
- sonarqube
- command: /bin/bash -e /usr/src/myapp/it/audit.sh
+ command: /bin/sh -e /usr/src/myapp/it/audit.sh
environment:
- SCANNER_VERSION:
+ SCANNER_VERSION: ${SCANNER_VERSION:-latest}
diff --git a/it/it.sh b/it/it.sh
old mode 100644
new mode 100755
index 38a14b8..eb2ae9a
--- a/it/it.sh
+++ b/it/it.sh
@@ -1,13 +1,39 @@
#!/bin/bash
-export SONARQUBE_VERSION="$1"
-export SCANNER_VERSION="$2"
-export JAVA_VERSION="$3"
-if [ -z "$SCANNER_VERSION" ]
-then
- echo "Missing parameters: Note: Removed in v0.3.3 - 2014-05-29 To avoid relying on strange and shell-specific behavior, any Removed in v0.3.3 - 2014-05-29 This You have escaped something that has no special meaning when escaped. The backslash will be simply be ignored. If the backslash was supposed to be literal, single quote or escape it. If you wanted it to expand to something, rewrite the expression to use None. ShellCheck (as of 2017-07-03, commit 31bb02d6) will not warn when the first letter of a command is unnecessarily escaped, as this is frequently used to suppress aliases interactively. None. ShellCheck (as of 2017-07-03, commit Want to escape a single quote? echo 'This is how it'\''s done'. Want to escape a single quote? (Note: in v0.4.6, the error message was accidentally missing the backslash) In POSIX shell, the shell cares about nothing but another single quote to terminate the quoted segment. Not even backslashes are interpreted. In POSIX shell, the shell cares about nothing but another single-quote to terminate the quoted segment. Not even backslashes are interpreted. POSIX.1 Shell Command Language § 2.2.2 Single Quotes: Enclosing characters in single-quotes ( Enclosing characters in single-quotes ( If you want your single quoted string to end in a backslash, you can rewrite as If you want your single-quoted string to end in a backslash, you can rewrite as This backslash+linefeed is literal. Break outside single quotes if you just want to break the line. (This warning was retired after 0.7.2 due to low signal-to-noise ratio) (This warning was retired after v0.7.2 due to low signal-to-noise ratio) You have a single quoted string containing a backslash followed by a linefeed (newline). Unlike double quotes or unquoted strings, this has no special meaning. The string will contain a literal backslash and a linefeed. You have a single-quoted string containing a backslash followed by a linefeed (newline). Unlike double-quotes or unquoted strings, this has no special meaning. The string will contain a literal backslash and a linefeed. If you wanted to break the line but not add a linefeed to the string, stop the single quote, break the line, and reopen it. This is demonstrated in the correct code. If you wanted to break the line and also include the linefeed as a literal, you don't need a backslash: It's easy to think that Instead, it runs It's easy to think that Instead, it runs Since trying to assign values this way is a common mistake, ShellCheck warns about it and asks you to be explicit when assigning empty strings (except for If you're familiar with this behavior and feel that the explicit version is unnecessary, you can [[ignore]] it. https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html
+https://mywiki.wooledge.org/BashPitfalls#foo_.3D_bar This shebang was unrecognized. ShellCheck only supports sh/bash/dash/ksh. Add a 'shell' directive to specify. If this is a script in some other language, like None. https://www.gnu.org/software/bash/manual/html_node/Shell-Scripts.html
+https://mywiki.wooledge.org/BashProgramming?highlight=%28shebang%29#Shebang
+https://www.gnu.org/software/gawk/manual/html_node/Executable-Scripts.html
+https://mywiki.wooledge.org/BashPitfalls#On_UTF-8_and_Byte-Order_Marks_.28BOM.29 This info warning points to the start of what ShellCheck was parsing when it failed. See [[Parser error]] for example and information. This info warning points to the start of what ShellCheck was parsing when it failed. See [[Parser error]] for example and information. Use semicolon or linefeed before 'done' (or quote to make it literal). Use semicolon or linefeed before (or or or ShellCheck found a keyword like In the example, In the example, If you're intentionally using If you're intentionally using From POSIX-2018, section "C.2.10 Shell Grammar," regarding the syntax, This apostrophe terminated the single quoted string! or When writing a string in single quotes, you have to make sure that any apostrophes in the text don't accidentally terminate the single quoted string prematurely. When writing a string in single-quotes, you have to make sure that any apostrophes in the text don't accidentally terminate the single-quoted string prematurely. Escape them properly (see the correct code) or switch quotes to avoid the problem. None. https://www.gnu.org/software/bash/manual/html_node/Quoting.html or or or ShellCheck has found a To generate such characters (plus other less common ones including ShellCheck has found a To generate such characters (plus other less common ones including Other characters like None. https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html#index-printf
+https://pubs.opengroup.org/onlinepubs/9799919799/utilities/printf.html
+https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html Use 'if cmd; then ..' to check exit code, or 'if [ "$(cmd)" = .. ]' to check output. Use If you want to check the exit status of a certain command, use that command directly as demonstrated in the correct code. If you want to check the output of a command, use There are certain shell syntaxes which can be wrapped directly around simple commands, in particular: Some examples include: Note how in example (2) If you want to check the exit status of a certain command, use that command directly as demonstrated in the correct code, above. If you want to check the output of a command, use For more information, see this problem in the Bash Pitfall list, or generally Tests and Conditionals in the WoolEdge BashGuide None. For more information, see this problem in the Bash Pitfall list, or generally Tests and Conditionals in the wooledge.org BashGuide This is a Unicode double quote. Delete and retype it. Blog software and word processors frequently replaces ASCII quotes Simply delete them and retype them in your editor. This error was retired after 0.4.5. In this version and earlier, ShellCheck parsed slanted quotes as a valid double quote. This meant that the warning could not simply be ignored. It has since been replaced by [[SC1110]] (outside quotes) and [[SC1111]] (inside double-quotes). If you really want literal Unicode double quotes, you can put them in single-quotes (or Unicode single-quotes in double-quotes) to make ShellCheck ignore them, e.g., This is a Unicode single quote. Delete and retype it. Some software, like macOS, Microsoft Word, and WordPress, may automatically replace your regular quotes with slanted Unicode quotes. Try deleting and retyping them, and/or disable “smart quotes” in your editor or OS. This error was retired after 0.4.5. In this version and earlier, ShellCheck parsed slanted quotes as a valid double-quote. This meant that the warning could not simply be ignored. It has since been replaced by [[SC1110]] (outside quotes) and [[SC1112]] (inside single-quotes). If you want to use typographic single-quotes, you can put them in double-quotes (or typographic double-quotes in single-quotes) to make ShellCheck ignore them, e.g., Literal carriage return. Run script through The script uses Windows/DOS style You can verify this with The script uses Windows/MS-DOS style You can verify this with If you don't know how to get your editor to save a file with Unix line terminators, you can use This will read a script None You copy-pasted some code, probably from a blog or web site, which for formatting reasons contained unicode no-break spaces or unicode zero-width spaces instead of regular spaces or in words. You copy-pasted some code, probably from a blog or web site, which for formatting reasons contained Unicode no-break spaces or Unicode zero-width spaces instead of regular spaces or in words. To humans, a zero-width space is invisible and a non-breaking space is indistinguishable from a regular space, but the shell does not agree. If you have just a few, delete the indiciated space/word and retype it. If you have tons, do a search&replace in your editor (copy-paste an offending space into the search field, and type a regular space into the replace field), or use If you have just a few, delete the indicated space/word and retype it. If you have tons, do a search-and-replace in your editor (copy-paste an offending space into the search field, and type a regular space into the replace field), or use the following command to remove them: On macOS, a non-breaking space can be inserted into most programs by holding ⌥ Option+Space. Expected this to be an argument to the unary condition. ShellCheck has found a unary test operator that does not appear to be followed by a valid shell word. You need a space before the "]" or "]]" You need a space before the Bourne shells are very whitespace sensitive. Adding or removing spaces can drastically alter the meaning of a script. In these cases, ShellCheck has noticed that you're missing a space at the position indicated. none. None. If grouping expressions inside [[..]], use ( .. ). If grouping expressions inside Expected another argument for this operator. Expected another argument for this operator. ShellCheck found a None. In [..] you have to escape \( \) or preferably combine [..] expressions. In In POSIX: Obsolete XSI syntax: In You don't have to -- and can't -- escape Test expression was opened with double (or SC1034 for vice versa) (or [[SC1034]] for vice versa) ShellCheck found a test expression Note in particular that You would instead use two separate test expressions joined by You need a space here Bourne shells are very whitespace sensitive. Adding or removing spaces can drastically alter the meaning of a script. In these cases, ShellCheck has noticed that you're missing a space at the position indicated. Depends on your intention: Determine what you intended the parenthesis to do and rewrite accordingly. Common issues include: Bash allows some parentheses as part of assignment-like tokens to certain commands, including In these cases, please quote the command, such as `eval "foo=(bar)". This does not change the behavior, but stops relying on bash specific parsing quirks. In these cases, please quote the command, such as Braces are required for positionals over 9, e.g. ${10}. Braces are required for positionals over 9, e.g. For legacy reasons, Curly braces are needed to tell the shell that both digits are part of the parameter expansion. If you wanted the trailing digits to be literal, If you wanted the trailing digits to be literal, In Shells are space sensitive. Use '< <(cmd)', not '<<(cmd)'. Shells are space sensitive. Use Remove indentation before end token (or use When using <<-, you can only indent with tabs. When using Any code using Code using Or simply don't indent the end token: Found 'eof' further down, but not on a separate line. Found Your here document isn't properly terminated. There is a line containing the terminator you've chosen, but it's not by itself on a separate line. In the example code, the script uses You will get some companion SC1042 errors mentioning lines that contain the string as a substring, though they all point to the start of the here document and not the relevant line: You will get some companion [[SC1042]] errors mentioning lines that contain the string as a substring, though they all point to the start of the here document and not the relevant line:$ is not used specially and should therefore be escaped.
+
+$ is not used specially and should therefore be escaped.Problematic code
-echo "$"
+echo "$"
Correct code
-echo "\$"
+echo "\$"
Rationale
$ is special in double quotes, but there are some cases where it's interpreted literally:
-
echo "\$""foo$") or before some constructs ("$'foo'").echo "\$""foo$") or before some constructs ("$'foo'").$ intended to be literal should be escaped with a backslash.\o will be a regular 'o' in this context.Problematic code
-# Want literal backslash
+# Want literal backslash
echo Yay \o/
# Want other characters
bell=\a
Correct code
-echo 'Yay \o/'
+echo 'Yay \o/'
-bell="$(printf '\a')"
+bell="$(printf '\a')"
Rationale
printf (or in bash, $'\t'). If the sequence in question is \n, \t or \r, you instead get a [[SC1012]] that describes this.Exceptions
-31bb02d6) will not warn when the first letter of a command is unnecessarily escaped, as this is frequently used to suppress aliases interactively.Related resources
+
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1003.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1003.html
index 54ad62b..172dc29 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1003.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1003.html
@@ -1,15 +1,16 @@
-echo 'This is how it'\''s done'.Problematic code
-echo 'This is not how it\'s done'.
+echo 'This is not how it\'s done'.
Correct code
-echo 'This is how it'\''s done'.
+echo 'This is how it'\''s done'.
Rationale
-'' ) shall preserve the literal value of each character within the single-quotes. A single-quote cannot occur within single-quotes.
+
'' ) shall preserve the literal value of each character within the single-quotes. A single-quote cannot occur within single-quotes.Exceptions
-'string'\\ or [[ignore]] this warning.'string'\\ or [[ignore]] this warning.Problematic code
-var='This is long \
-piece of text'
+var='This is long \
+piece of text'
Correct code
-var='This is a long '\
-'piece of text'
+var='This is a long '\
+'piece of text'
Rationale
-var='This is a multi-line string
+var='This is a multi-line string
with an embedded linefeed'
Exceptions
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1007.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1007.html
index dd103e9..22e5f5c 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1007.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1007.html
@@ -1,21 +1,24 @@
-Remove space after = if trying to assign a value (or for empty string, use var='' ... ).
+Remove space after
= if trying to assign a value (or for empty string, use var="" ... ).Problematic code
-# I want programs to show text in dutch!
+
-# I want programs to show text in Dutch!
LANGUAGE= nl
# I want to run the nl command with English error messages!
+# I want to run the nl command with English error messages!
LANGUAGE= nl
Correct code
-# I want programs to show text in dutch!
+
-# I want programs to show text in Dutch!
LANGUAGE=nl
# I want to run the nl command with English error messages!
-LANGUAGE='' nl
+# I want to run the nl command with English error messages!
+LANGUAGE='' nl
Rationale
-LANGUAGE= nl would assign "nl" to the variable LANGUAGE. It doesn't.nl (the "number lines" command) and sets LANGUAGE to an empty string in its environment.LANGUAGE= nl would assign "nl" to the variable LANGUAGE. It doesn't.nl (the "number lines" command) and sets LANGUAGE to an empty string in its environment.IFS, due to the common IFS= read .. idiom).Exceptions
Related Resources
+Problematic code
-#!/bin/mywrapper
+#!/bin/mywrapper
echo "Hello World"
Correct code
-#!/bin/mywrapper
+
@@ -14,7 +14,11 @@ #!/bin/mywrapper
# shellcheck shell=bash
echo "Hello World"
Rationale
#!/bin/sed for a sed script, then sorry -- ShellCheck does not support sed, awk, expect scripts. It only supports Bourne style shell scripts.Exceptions
Related resources
+Related Resources
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1009.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1009.html
index 5cbe31d..72e8116 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1009.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1009.html
@@ -1,2 +1,2 @@
The mentioned parser error was in ...
-done (or quote to make it literal).do then, fi, esac)Problematic code
-for f in *; do echo "$f" done
+for f in *; do echo "$f" done
echo $f is done
+echo $f is done
Correct code
-for f in *; do echo "$f"; done
+for f in *; do echo "$f"; done
echo "$f is done"
+echo "$f is done"
Rationale
done, then, fi, esac, etc used as the argument of a command. This means that the shell will interpret it as a literal string rather than a shell keyword. To be interpreted as a keyword, it must be the first word in the line (i.e. after ;, & or a linefeed).echo "$f" done is the same as echo "$f" "done", and the done does not terminate the loop. This is fixed by terminating the echo command with a ; so that the done is the first word in the next line.echo "$f" done is the same as echo "$f" "done", and the done does not terminate the loop. This is fixed by terminating the echo command with a ; so that the done is the first word in the next line.Exceptions
-done as a literal, you can quote it to make this clear to shellcheck (and also human readers), e.g. instead of echo Task is done, use echo "Task is done". This makes no difference to the shell, but it will silence this warning.done as a literal, you can quote it to make this clear to ShellCheck (and also human readers), e.g. instead of echo Task is done, use echo "Task is done". This makes no difference to the shell, but it will silence this warning.if (false) then (echo x) else (echo y) fi:
+https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html#tag_23_02_10Problematic code
-echo 'Nothing so needs reforming as other people's habits.'
+echo 'Nothing so needs reforming as other peoples' habits.'
Correct code
-echo 'Nothing so needs reforming as other people'\''s habits.'
+echo 'Nothing so needs reforming as other peoples'\'' habits.'
echo "Nothing so needs reforming as other people's habits."
+echo "Nothing so needs reforming as other peoples' habits."
Rationale
-Additional options
+
+echo '...peoples\ habits.'
+...peoples\ habits.
+$ echo $'...peoples\x27 habits.'
+...peoples' habits.
+Exceptions
Related Resources
+\t is just literal t here. For tab, use "$(printf '\t')" instead.\t is just literal t here. For tab, use "$(printf '\t')" instead.Problematic code
-# Want tab
-var=foo\tbar
+# Want tab
+$ var=foo\tbar
+$ printf '<%s>\n' "$var"
+<footbar>
+
+$ var=foo\\tbar
+$ printf '<%s>\n' "$var"
+<foo\tbar>
+
# Want linefeed
-var=foo\nbar
+# Want newline
+$ var=foo\nbar
+$ printf '<%s>\n' "$var"
+<foonbar>
+
+$ var=foo\\nbar
+$ printf '<%s>\n' "$var"
+<foo\nbar>
Correct code
-var="foo$(printf '\t')bar" # As suggested in warning
-var="$(printf 'foo\tbar')" # Equivalent alternative
+$ var="foo$(printf '\t')bar" # As suggested in warning
+$ printf '<%s>\n' "$var"
+<foo bar>
+
+$ var="$(printf 'foo\tbar')" # Equivalent alternative
+$ printf '<%s>\n' "$var"
+<foo bar>
# Literal, quoted linefeed
-line="foo
-bar"
+
+$ # Literal, quoted newline
+$ line="foo
+> bar"
+$ printf '<%s>\n' "$line"
+<foo
+bar>
+$ # Newline using ANSI-C quoting
+$ line=$'foo\nbar'
+$ printf '<%s>\n' "$line"
+<foo
+bar>
Rationale
-\t, \n or \r in a context where they just become regular letter t, n or r. Most likely, it was intended as a tab, linefeed or carriage return.\a, \f and octal escapes) , use printf as in the example. The exception is for linefeeds that would be stripped by command substitution; in these cases, use a literal quoted linefeed instead.\t, \n or \r in a context where they just become regular letters t, n or r. Most likely, it was intended as a tab, newline or carriage return.\a, \f and octal escapes) , use printf as in the example. The exception is for newliness that would be stripped by command substitution; in these cases, use a literal quoted newline instead.\z generate a [[SC1001]] info message, as the intent is less certain.Exceptions
Related resources
+Related Resources
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1012.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1012.json
index 2f207db..d3694b5 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1012.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1012.json
@@ -1,5 +1,5 @@
{
- "title": "\\t is just literal t here. For tab, use '$(printf '\\t')' instead.",
+ "title": "\\t is just literal t here. For tab, use "$(printf '\\t')" instead.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1014.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1014.html
index 4dac973..0d73aa6 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1014.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1014.html
@@ -1,32 +1,62 @@
-if cmd; then .. to check exit code, or if [ "$(cmd)" = .. ] to check output.Problematic code
-if [ grep -q pattern file ]
+
+# WRONG
+if [ grep -q pattern file ]
then
echo "Found a match"
fi
# WRONG
+if ! [[ logname == $LOGNAME ]]
+then
+ echo "Possible `su` shell"
+fi
+Correct code
-if grep -q pattern file
+
+if grep -q pattern file
then
echo "Found a match"
fi
if ! [[ $(logname) == $LOGNAME ]]
+then
+ echo "Possible `su` shell"
+fi
+Rationale
-[ .. ] is not part of shell syntax like if statements. It is not equivalent to parentheses in C-like languages, if (foo) { bar; }, and should not be wrapped around commands to test.[ is just regular command, like whoami or grep, but with a funny name (see ls -l /bin/[). It's a shorthand for test."$(..)" to get its output, and then use test or [/[[ to do a string comparison:# Check output of `whoami` against the string `root`
+[ ... ] as shell syntax is a simple command that tests for whether certain conditions are true or false, such as whether the value assigned to a variable has a non-zero length ([ -n "${foo}" ]) or whether a file system object is a directory ([ -d "${dir}" ]). If-then-(elif-then)-else-fi statements are logical constructs which themselves contain lists of commands which can include simple commands.[ is just regular command, like whoami or grep, but with a funny name (see ls -l /bin/[). It's a shorthand for test. [[ is similar to both [ and test, but [[ offers some additional unary operators, such as '=~' the regular expression comparison operator. It allows one to use extglobs such as @(foo|bar) (a "bashism"), among some other less commonly used features.[[, [ and test are often used within if...fi constructs in the conditional commands position: which is between the 'if' and the 'then.'
+
+{ ...;}, group commands,$( ... ), command substitutions,<( ... ) and >( ... ), process substitutions,( ... ), subshells, and$(( ... )) and (( ... )), arithmetic evaluations.
+
+{ echo {a..z}; echo {0..9};} > ~/f,[[ $(logname) == $LOGNAME ]],readarray -t files < <( find ...),(cd /foo || exit 1; tar ...), anddd bs=$((2**12)) count=1 if=/dev/zero of=/tmp/zeroed-block, respectively.logname is enclosed directly within a command substitution, which is itself enclosed within a [[ reserved word / conditional expression / compound command."$(..)" to get its output, and then use test/[ or [[ to do a string comparison:
-# Check output of `whoami` against the string `root`
if [ "$(whoami)" = "root" ]
then
echo "Running as root"
fi
Exceptions
Related resources
+Related Resources
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1014.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1014.json
index 27e4edb..86fbdec 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1014.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1014.json
@@ -1,5 +1,5 @@
{
- "title": "Use 'if cmd; then ..' to check exit code, or 'if [ '$(cmd)' = .. ]' to check output.",
+ "title": "Use if cmd; then .. to check exit code, or if [ "$(cmd)" = .. ] to check output.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1015.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1015.html
new file mode 100644
index 0000000..d902db1
--- /dev/null
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1015.html
@@ -0,0 +1,16 @@
+if [grep foo myfile]Problematic code
+
+echo “hello world”
+Correct code
+
+echo "hello world"
+Rationale
+"" with fancy Unicode quotes, “”. To Bash, Unicode quotes are considered regular literals and not quotes at all.Status
+Exceptions
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1015.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1015.json
new file mode 100644
index 0000000..65b0fde
--- /dev/null
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1015.json
@@ -0,0 +1,14 @@
+{
+ "title": "This is a Unicode double quote. Delete and retype it.",
+ "type": "CODE_SMELL",
+ "status": "ready",
+ "remediation": {
+ "func": "Constant\/Issue",
+ "constantCost": "2min"
+ },
+ "tags": [
+ "shell",
+ "convention"
+ ],
+ "defaultSeverity": "Major"
+}
\ No newline at end of file
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1016.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1016.html
new file mode 100644
index 0000000..498402f
--- /dev/null
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1016.html
@@ -0,0 +1,15 @@
+printf 'Warning: “wakeonlan” is not installed.\n'
+Problematic code
+
+echo ‘hello world’
+Correct code
+
+echo 'hello world'
+Rationale
+Status
+Exceptions
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1016.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1016.json
new file mode 100644
index 0000000..02fe932
--- /dev/null
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1016.json
@@ -0,0 +1,14 @@
+{
+ "title": "This is a Unicode single quote. Delete and retype it.",
+ "type": "CODE_SMELL",
+ "status": "ready",
+ "remediation": {
+ "func": "Constant\/Issue",
+ "constantCost": "2min"
+ },
+ "tags": [
+ "shell",
+ "convention"
+ ],
+ "defaultSeverity": "Major"
+}
\ No newline at end of file
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1017.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1017.html
index 192b97c..3f5d8e4 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1017.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1017.html
@@ -1,25 +1,27 @@
printf "Warning: ‘wakeonlan’ is not installed.\n"
+tr -d '\r' .Problematic code
-$ cat -v myscript
+$ cat -v myscript
#!/bin/sh^M
echo "Hello World"^M
Correct code
-$ cat -v myscript
+$ cat -v myscript
#!/bin/sh
echo "Hello World"
Rationale
-\r\n line terminators instead of UNIX style \n terminators. The additional \r aka ^M aka carriage return characters will be treated literally, and results in all sorts strange bugs and messages.cat -v yourfile and see whether or not each line ends with a ^M. To delete them, open the file in your editor and save the file as "Unix", "UNIX/OSX Format", :set ff=unix or similar if it supports it.\r\n line terminators instead of Unix-style \n terminators. The additional \r aka ^M aka carriage return characters will be treated literally, and results in all sorts strange bugs and messages.cat -v yourfile and see whether or not each line ends with a ^M. To delete them, open the file in your editor and save the file as "Unix", "Unix/macOS Format", :set ff=unix or similar if it supports it.tr:tr -d '\r' < badscript > goodscript
+tr -d '\r' < badscript > goodscript
+# or
+dos2unix badscript
badscript with possible carriage returns, and write goodscript without them.Exceptions
Related resources
-
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1018.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1018.html
index af3c8b6..09931ee 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1018.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1018.html
@@ -1,4 +1,7 @@
-This is a unicode non-breaking space. Delete it and retype as space.
-This is a Unicode non-breaking space. Delete it and retype as space.
+sed -e $'s/\xC2\xA0/ /g' -e $'s/\xE2\x80\x8b//g' -i yourfile to remove them.
+sed -e $'s/\xC2\xA0/ /g' -e $'s/\xE2\x80\x8b//g' -i yourfile
+Problematic code
-[ -x ]
+[ -x ]
Correct code
-[ -x "myfile" ]
+[ -x "myfile" ]
Rationale
] or ]]Problematic code
-if [ "$STUFF" = ""]; then
+if [ "$STUFF" = ""]; then
Correct code
-if [ "$STUFF" = "" ]; then
+if [ "$STUFF" = "" ]; then
Rationale
Exceptions
-Ignore
-# shellcheck disable=SC1020
-if [ "$STUFF" = ""]; then
-...
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1020.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1020.json
index 80ecfbe..b459afc 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1020.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1020.json
@@ -1,5 +1,5 @@
{
- "title": "You need a space before the ']' or ']]'",
+ "title": "You need a space before the ] or ]]",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1026.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1026.html
index d3b8910..87d0a96 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1026.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1026.html
@@ -1,10 +1,10 @@
-# shellcheck disable=SC1020
+if [ "$STUFF" = ""]; then
[[..]], use ( .. ).Problematic code
-[[ [ a || b ] && c ]]
+[[ [ a || b ] && c ]]
[ [ a -o b ] -a c ]]
Correct code
-[[ ( a || b ) && c ]]
+[[ ( a || b ) && c ]]
[ \( a -o b \) -a c ]] # or { [ a ] || [ b ]; } && [ c ]
Rationale
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1027.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1027.html
index 5575210..8342937 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1027.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1027.html
@@ -1 +1,15 @@
-Problematic code
+
+[ $a -ne ]
+Correct code
+
+[ $a -ne $b ]
+Rationale
+test operator without an operand. This could be a copy-paste fail, bad linebreak, or trying to use <> instead of != or -ne.Exceptions
+Related resources
+
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1028.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1028.html
index 33f7a27..bcb06d1 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1028.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1028.html
@@ -1,13 +1,13 @@
-[..] you have to escape \( \) or preferably combine [..] expressions.Problematic code
-[ -e ~/.bashrc -a ( -x /bin/dash -o -x /bin/ash ) ]
+[ -e ~/.bashrc -a ( -x /bin/dash -o -x /bin/ash ) ]
Correct code
[ -e ~/.bashrc ] && { [ -x /bin/dash ] || [ -x /bin/ash ]; }
+[ -e ~/.bashrc ] && { [ -x /bin/dash ] || [ -x /bin/ash ]; }
[ -e ~/.bashrc -a \( -x /bin/dash -o -x /bin/ash \) ]
+[ -e ~/.bashrc -a \( -x /bin/dash -o -x /bin/ash \) ]
Rationale
[ is implemented as a regular command, so ( is not special.[[..]] you shouldn't escape ( or ).Problematic code
-[[ -e ~/.bashrc -a \( -x /bin/dash -o -x /bin/ash \) ]]
+[[ -e ~/.bashrc && \( -x /bin/dash || -x /bin/ash \) ]]
Correct code
-[[ -e ~/.bashrc -a ( -x /bin/dash -o -x /bin/ash ) ]]
+[[ -e ~/.bashrc && ( -x /bin/dash || -x /bin/ash ) ]]
Rationale
( or ) inside a [[ .. ]] expression like you do in [ .. ]. Just remove the escaping.[[ but closed with single ]. Make sure they match.Problematic code
-[[ -z "$var" ]
+[[ -z "$var" ]
Correct code
-[[ -z "$var" ]]
+[[ -z "$var" ]]
Rationale
[ ... ] (POSIX) or [[ ... ]] (ksh/bash), but where the opening and closing brackets did not match (i.e. [[ .. ] or [ .. ]]). The brackets need to match up to work.[..] do not work like parentheses in other languages. You can not do:# Invalid
+# Invalid
[[ x ] || [ y ]]
||:# Valid basic test expressions (sh/bash/ksh)
+# Valid basic test expressions (sh/bash/ksh)
[ x ] || [ y ]
# Valid extended test expressions (bash/ksh)
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1035.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1035.html
index 59e0ec8..1879a1b 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1035.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1035.html
@@ -1,9 +1,9 @@
Problematic code
-if ![-z foo ]; then true; fi # if command `[-z' w/ args `foo', `]' fails..
+if ![-z foo ]; then true; fi # if command `[-z' w/ args `foo', `]' fails..
Correct code
-if ! [ -z foo ]; then true; fi # if command `[' w/ args `-z', `foo', `]' fails..
+if ! [ -z foo ]; then true; fi # if command `[' w/ args `-z', `foo', `]' fails..
Rationale
( is invalid here. Did you forget to escape it?Problematic code
-echo (foo) bar
+echo (foo) bar
Correct code
echo "(foo) bar" # Literal parentheses
+
@@ -13,16 +13,16 @@ echo "(foo) bar" # Literal parentheses
echo "$(foo) bar" # Command expansion
echo "foo bar" # Tried to use parentheses for grouping or function invocation
Rationale
echo (FAIL) Some tests failed. In this case, it requires quoting.echo Today is (date). Add the missing $: echo "Today is $(date)"echo Today is (date). Add the missing $: echo "Today is $(date)"foo (bar, 42) to call a function. This should be foo bar 42. Also, shells do not support tuples or passing arrays as single parameters.Exceptions
export and eval. This is a workaround in Bash to allow commands that normally would not be valid:eval foo=(bar) # Valid command
+
-eval foo=(bar) # Valid command
echo foo=(bar) # Invalid syntax
f=foo; eval $f=(bar) # Also invalid
eval "foo=(bar)". This does not change the behavior, but stops relying on Bash-specific parsing quirks.Related resources
${10}.Problematic code
-echo "Ninth parameter: $9"
+echo "Ninth parameter: $9"
echo "Tenth parameter: $10"
Correct code
-echo "Ninth parameter: $9"
+echo "Ninth parameter: $9"
echo "Tenth parameter: ${10}"
Rationale
$10 is interpreted as the variable $1 followed by the literal string 0.Exceptions
-${1}0 will make this clear to both humans and shellcheck.${1}0 will make this clear to both humans and ShellCheck.dash, $10 is (wrongly) interpreted as ${10}, so some 'reversed' care should also be taken:bash -c 'set a b c d e f g h i j; echo $10 ${1}0' # POSIX: a0 a0
-dash -c 'set a b c d e f g h i j; echo $10 ${1}0' # WRONG: j a0
+bash -c 'set a b c d e f g h i j; echo $10 ${1}0' # POSIX: a0 a0
+dash -c 'set a b c d e f g h i j; echo $10 ${1}0' # WRONG: j a0
Related resources
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1038.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1038.html
index 8a06afd..fd4875e 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1038.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1038.html
@@ -1,12 +1,12 @@
-< <(cmd), not <<(cmd).Problematic code
-while IFS= read -r line
+while IFS= read -r line
do
printf "%q\n" "$line"
done <<(curl -s http://example.com)
Correct code
-while IFS= read -r line
+while IFS= read -r line
do
printf "%q\n" "$line"
done < <(curl -s http://example.com)
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1038.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1038.json
index 9d3ebd7..ca97354 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1038.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1038.json
@@ -1,5 +1,5 @@
{
- "title": "Shells are space sensitive. Use '< <(cmd)', not '<<(cmd)'.",
+ "title": "Shells are space sensitive. Use < <(cmd), not <<(cmd).",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1039.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1039.html
index 54f5325..23d41a1 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1039.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1039.html
@@ -1,18 +1,18 @@
<<- and indent with tabs).Problematic code
-for f in *.png
+for f in *.png
do
- cat << EOF
+ cat << HTML
<img src="$f" /><br/>
- EOF
+ HTML
done > index.html
Correct code
-for f in *.png
+for f in *.png
do
- cat << EOF
+ cat << HTML
<img src="$f" /><br/>
-EOF
+HTML
done > index.html
Rationale
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1040.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1040.html
index d224966..feae993 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1040.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1040.html
@@ -1,18 +1,18 @@
-<<-, you can only indent with tabs.Problematic code
<<- that is indented with spaces. cat -T script shows cat <<- foo
+ cat <<- foo
Hello world
foo
Correct code
<<- must be indented with tabs. cat -T script shows^Icat <<- foo
+^Icat <<- foo
^I^IHello world
^Ifoo
cat <<- foo
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1041.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1041.html
index 0f9fc7b..a744fc8 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1041.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1041.html
@@ -1,13 +1,12 @@
- cat <<- foo
Hello World
foo
+Close matches include '-eof' (!= 'eof').
-eof further down, but not on a separate line.Close matches include '-eof' (!= 'eof').Problematic code
-cat <<-eof
+cat <<-eof
Hello World
-eof
Correct code
-cat <<- eof
+
@@ -15,7 +14,7 @@ cat <<- eof
Hello World
eof
Rationale
<<-eof, which is the operator <<- followed by eof. The script therefore looks for eof and skips right past the intended terminator because it starts with a dash.In foo line 4:
Hello
^-- SC1041: Found 'eof' further down, but not on a separate line.
@@ -26,5 +25,5 @@ Rationale
Try to change the line ending into LF.
None.
-Note that SC1041 and SC1042 swapped numbers after v0.4.6 to improve the display order. This rare instance of number reuse was justified by them always occuring together on the same line.
+Note that SC1041 and [[SC1042]] swapped numbers after v0.4.6 to improve the display order. This rare instance of number reuse was justified by them always occurring together on the same line.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1041.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1041.json index 10c5b55..6417468 100644 --- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1041.json +++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1041.json @@ -1,5 +1,5 @@ { - "title": "Found 'eof' further down, but not on a separate line.", + "title": "Found eof further down, but not on a separate line.", "type": "CODE_SMELL", "status": "ready", "remediation": { diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1043.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1043.html index 8e4d984..e7c2418 100644 --- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1043.html +++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1043.html @@ -1 +1,19 @@ -Found end token `EOF' further down, but with wrong casing.
\ No newline at end of file +Found EOF further down, but with wrong casing.
+cat << EOF
+Hello World
+Eof
+
+cat << EOF
+Hello World
+EOF
+
+ShellCheck found a here document (<<) where the end token is missing. However, the end token appears with different case further down. If this was meant to be the end of the here document, make sure the case matches.
None. This error is only emitted when the here document is incomplete.
+Couldn't find end token `EOF' in the here document.
+Couldn't find end token EOF in the here document.
cat << EOF
+cat << EOF
Hello World
Correct code
-cat << EOF
+cat << EOF
Hello World
EOF
Rationale
The << here document (aka heredoc) was not properly terminated. The terminating token needs to be on a separate line without indenting (or indented with tabs only when using <<-).
Note that you can not put here documents in one liners. For such use cases, use a <<< here string:
-cat << EOF hello world EOF # Wrong: data and terminator can not be on the same line
-cat <<< "hello world" # Correct
+cat << EOF hello world EOF # Wrong: data and terminator can not be on the same line
+cat <<< "hello world" # Correct
Exceptions
None
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1044.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1044.json
index 6f613c6..58c90a2 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1044.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1044.json
@@ -1,5 +1,5 @@
{
- "title": "Couldn't find end token `EOF' in the here document.",
+ "title": "Couldn't find end token EOF in the here document.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1045.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1045.html
index d7ef277..fa2c087 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1045.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1045.html
@@ -1,9 +1,9 @@
-It's not 'foo &; bar', just 'foo & bar'.
+It's not foo &; bar, just foo & bar.
Problematic code
-foo &; bar
+foo &; bar
Correct code
-foo & bar
+foo & bar
Rationale
Both & and ; terminate the command. You should only use one of them.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1045.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1045.json
index 2a13c4d..6f707e1 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1045.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1045.json
@@ -1,5 +1,5 @@
{
- "title": "It's not 'foo &; bar', just 'foo & bar'.",
+ "title": "It's not foo &; bar, just foo & bar.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1046.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1046.html
index da9a7ad..d1f2c1d 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1046.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1046.html
@@ -1,12 +1,12 @@
-Couldn't find 'fi' for this 'if'.
+Couldn't find fi for this if.
Problematic code
-if true
+if true
then
echo "True"
done
Correct code
-if true
+if true
then
echo "True"
fi
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1046.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1046.json
index 450af8a..78392c8 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1046.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1046.json
@@ -1,5 +1,5 @@
{
- "title": "Couldn't find 'fi' for this 'if'.",
+ "title": "Couldn't find fi for this if.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1047.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1047.html
index 5cc7a6b..5048bec 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1047.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1047.html
@@ -1,2 +1,2 @@
-"Expected 'fi' matching previously mentioned 'if'.
+Expected fi matching previously mentioned if.
See companion warning [[SC1046]].
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1047.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1047.json
index 938f394..65447cd 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1047.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1047.json
@@ -1,5 +1,5 @@
{
- "title": "'Expected 'fi' matching previously mentioned 'if'.",
+ "title": "Expected fi matching previously mentioned if.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1048.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1048.html
index eb6aec5..f49aad3 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1048.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1048.html
@@ -1,12 +1,12 @@
-Can't have empty then clauses (use 'true' as a no-op).
+Can't have empty then clauses (use true as a no-op).
Problematic code
-if [ -e foo ]
+if [ -e foo ]
then
# TODO: handle this
fi
Correct code
-if [ -e foo ]
+if [ -e foo ]
then
# TODO: handle this
true
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1048.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1048.json
index fdd38b1..fcbd973 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1048.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1048.json
@@ -1,5 +1,5 @@
{
- "title": "Can't have empty then clauses (use 'true' as a no-op).",
+ "title": "Can't have empty then clauses (use true as a no-op).",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1049.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1049.html
index 472ed5d..131b22c 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1049.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1049.html
@@ -1,13 +1,13 @@
-Did you forget the 'then' for this 'if'?
+Did you forget the then for this if?
Problematic code
-if true
+if true
echo "foo"
elif true
echo "bar"
fi
Correct code
-if true
+if true
then
echo "foo"
elif true
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1049.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1049.json
index a6c652f..13bafd5 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1049.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1049.json
@@ -1,5 +1,5 @@
{
- "title": "Did you forget the 'then' for this 'if'?",
+ "title": "Did you forget the then for this if?",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1050.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1050.html
index 907620b..2ca2f90 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1050.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1050.html
@@ -1,11 +1,11 @@
-Expected 'then'.
+Expected then.
Problematic code
-if true
+if true
echo "True"
fi
Correct code
-if true
+if true
then
echo "True"
fi
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1050.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1050.json
index 2ec95ff..74646b3 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1050.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1050.json
@@ -1,5 +1,5 @@
{
- "title": "Expected 'then'.",
+ "title": "Expected then.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1051.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1051.html
index a51e204..36fbd53 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1051.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1051.html
@@ -1,9 +1,9 @@
-Semicolons directly after 'then' are not allowed. Just remove it.
+Semicolons directly after then are not allowed. Just remove it.
Problematic code
-if true; then; echo "Hi"; fi
+if true; then; echo "Hi"; fi
Correct code
-if true; then echo "Hi"; fi
+if true; then echo "Hi"; fi
Rationale
then keywords should not be followed by semicolons. It's not valid shell syntax.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1051.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1051.json
index 85baf18..7c7bd72 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1051.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1051.json
@@ -1,5 +1,5 @@
{
- "title": "Semicolons directly after 'then' are not allowed. Just remove it.",
+ "title": "Semicolons directly after then are not allowed. Just remove it.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1052.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1052.html
index a51e204..36fbd53 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1052.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1052.html
@@ -1,9 +1,9 @@
-Semicolons directly after 'then' are not allowed. Just remove it.
+Semicolons directly after then are not allowed. Just remove it.
Problematic code
-if true; then; echo "Hi"; fi
+if true; then; echo "Hi"; fi
Correct code
-if true; then echo "Hi"; fi
+if true; then echo "Hi"; fi
Rationale
then keywords should not be followed by semicolons. It's not valid shell syntax.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1052.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1052.json
index 85baf18..7c7bd72 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1052.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1052.json
@@ -1,5 +1,5 @@
{
- "title": "Semicolons directly after 'then' are not allowed. Just remove it.",
+ "title": "Semicolons directly after then are not allowed. Just remove it.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1053.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1053.html
index da54cf7..249c14a 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1053.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1053.html
@@ -1,9 +1,9 @@
-Semicolons directly after 'else' are not allowed. Just remove it.
+Semicolons directly after else are not allowed. Just remove it.
Problematic code
-if mycommand; then echo "True"; else; echo "False"; fi
+if mycommand; then echo "True"; else; echo "False"; fi
Correct code
-if mycommand; then echo "True"; else echo "False"; fi
+if mycommand; then echo "True"; else echo "False"; fi
Rationale
else keywords should not be followed by semicolons. It's not valid shell syntax.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1053.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1053.json
index 043659b..7f2ab38 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1053.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1053.json
@@ -1,5 +1,5 @@
{
- "title": "Semicolons directly after 'else' are not allowed. Just remove it.",
+ "title": "Semicolons directly after else are not allowed. Just remove it.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1054.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1054.html
index 0f11857..de3bed0 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1054.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1054.html
@@ -1,12 +1,12 @@
-You need a space after the '{'.
+You need a space after the {.
Problematic code
-foo() {echo "hello world;}
+foo() {echo "hello world"; }
Correct code
-foo() { echo "hello world;}
+foo() { echo "hello world"; }
Rationale
{ is only recognized as the start of a command group when it's a separate token.
-If it's not a separate token, like in the problematic example, it will be considered a literal character, as if writing "{echo" with quotes, and therefore usually cause a syntax error.
+If it's not a separate token, like in the problematic example, it will be considered a literal character, as if writing "{echo" with quotes, and therefore usually cause a syntax error.
Exceptions
None.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1054.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1054.json
index 82b687f..1c75e2f 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1054.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1054.json
@@ -1,5 +1,5 @@
{
- "title": "You need a space after the '{'.",
+ "title": "You need a space after the {.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1055.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1055.html
index 3d171b0..5d9cdda 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1055.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1055.html
@@ -1 +1,21 @@
-You need at least one command here. Use 'true;' as a no-op.
\ No newline at end of file
+You need at least one command here. Use true; as a no-op.
+Problematic code
+submitbug() {
+ # TODO: Implement me
+}
+
+Correct code
+submitbug() {
+ # TODO: Implement me
+ true
+}
+
+Rationale
+ShellCheck found an empty code block. This could be an empty function as shown, a loop with an empty body, or similar.
+Sh/bash does not allow empty code blocks. Insert at least one command. If you don't want the block to do anything, true (aka :) is a good no-op.
+Exceptions
+None
+Related resources
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1055.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1055.json
index 379f947..34726d1 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1055.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1055.json
@@ -1,5 +1,5 @@
{
- "title": "You need at least one command here. Use 'true;' as a no-op.",
+ "title": "You need at least one command here. Use true; as a no-op.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1056.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1056.html
index 332811b..7829276 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1056.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1056.html
@@ -1,12 +1,12 @@
-Expected a '}'. If you have one, try a ; or \n in front of it.
+Expected a }. If you have one, try a ; or \n in front of it.
Problematic code
-#!/bin/bash
+#!/bin/bash
bar() { echo "hello world" }
Correct code
-#!/bin/bash
+#!/bin/bash
bar() { echo "hello world";}
Rationale
} is only recognized as the end of a command group when it's a separate token.
-If it's not a separate token, like in the problematic example, it will be considered a literal character, as if writing echo "foo}" with quotes, and therefore usually cause a syntax error.
+If it's not a separate token, like in the problematic example, it will be considered a literal character, as if writing echo "foo}" with quotes, and therefore usually cause a syntax error.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1056.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1056.json
index 536da73..861055d 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1056.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1056.json
@@ -1,5 +1,5 @@
{
- "title": "Expected a '}'. If you have one, try a ; or \\n in front of it.",
+ "title": "Expected a }. If you have one, try a ; or \\n in front of it.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1057.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1057.html
index 9a42ebe..9baa100 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1057.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1057.html
@@ -1 +1,20 @@
-Did you forget the 'do' for this loop?
\ No newline at end of file
+Did you forget the do for this loop?
+Problematic code
+while read -r line
+ echo $line
+done
+
+Correct code
+while read -r line
+do
+ echo $line
+done
+
+Rationale
+ShellCheck found a loop that appears to be missing its do statement. Make sure the loop syntax is correct.
+Exceptions
+None.
+Related resources
+
+- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1057.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1057.json
index 08c9b47..436235f 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1057.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1057.json
@@ -1,5 +1,5 @@
{
- "title": "Did you forget the 'do' for this loop?",
+ "title": "Did you forget the do for this loop?",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1058.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1058.html
index e8dee2d..1a733de 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1058.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1058.html
@@ -1,11 +1,11 @@
Expected do.
Problematic code
-for file in *
+for file in *
echo "$file"
done
Correct code
-for file in *
+for file in *
do
echo "$file"
done
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1059.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1059.html
index 6a30164..ac7a38c 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1059.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1059.html
@@ -1 +1,25 @@
-No semicolons directly after 'do'.
\ No newline at end of file
+Semicolon is not allowed directly after do. You can just delete it.
+Problematic code
+while true; do; true; done
+
+while true;
+do;
+ true;
+done;
+
+Correct code
+while true; do true; done
+
+while true;
+do
+ true;
+done;
+
+Rationale
+Semicolon ; is not allowed directly after a do keyword. Follow it directly with either a command or a linefeed as shown in the example.
+Exceptions
+None.
+Related resources
+
+- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1059.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1059.json
index e2536c5..0fafa9c 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1059.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1059.json
@@ -1,5 +1,5 @@
{
- "title": "No semicolons directly after 'do'.",
+ "title": "Semicolon is not allowed directly after do. You can just delete it.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1060.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1060.html
index bc94d19..6ae5a75 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1060.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1060.html
@@ -1 +1,19 @@
-Can't have empty do clauses (use 'true' as a no-op).
\ No newline at end of file
+Can't have empty do clauses (use true as a no-op)
+Problematic code
+for i in 1 2 3; do
+done
+
+Correct code
+for i in 1 2 3; do
+ true
+done
+
+Rationale
+An empty do ... done block is not valid.
+Use true or : if you need no command at all.
+Exceptions
+None.
+Related resources
+
+- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1060.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1060.json
index aa30ff1..666288c 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1060.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1060.json
@@ -1,5 +1,5 @@
{
- "title": "Can't have empty do clauses (use 'true' as a no-op).",
+ "title": "Can't have empty do clauses (use true as a no-op)",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1061.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1061.html
index ffc3af9..878c2b2 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1061.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1061.html
@@ -1,13 +1,13 @@
-Couldn't find 'done' for this 'do'.
+Couldn't find done for this do.
Problematic code
-yes() {
+yes() {
while echo "y"
do
true
}
Correct code
-yes() {
+yes() {
while echo "y"
do
true
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1061.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1061.json
index 212e5ef..b683855 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1061.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1061.json
@@ -1,5 +1,5 @@
{
- "title": "Couldn't find 'done' for this 'do'.",
+ "title": "Couldn't find done for this do.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1062.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1062.html
index f834ce1..287e57a 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1062.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1062.html
@@ -1,2 +1,2 @@
-Expected 'done' matching previously mentioned 'do'.
+Expected done matching previously mentioned do.
See companion warning [[SC1061]]
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1062.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1062.json
index d7bbf61..c3cefad 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1062.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1062.json
@@ -1,5 +1,5 @@
{
- "title": "Expected 'done' matching previously mentioned 'do'.",
+ "title": "Expected done matching previously mentioned do.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1063.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1063.html
index 2971ff7..d647929 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1063.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1063.html
@@ -1 +1,31 @@
-You need a line feed or semicolon before the 'do'.
\ No newline at end of file
+You need a line feed or semicolon before the do.
+Problematic code
+for file in * do
+ echo "$file"
+done
+
+Correct code
+for file in *; do
+ echo "$file"
+done
+
+# or
+
+for file in *
+do
+ echo "$file"
+done
+
+Rationale
+ShellCheck found a do on the same line as a loop, but do only starts a loop block at the start of a line/statement. Make the do the start of a new line/statement by inserting a linefeed or semicolon in front of it.
+Exceptions
+If you wanted to treat do as a literal string, you can quote it to make this clear to ShellCheck and humans:
+for f in "for" "do" "done"
+do
+ echo "Shell keywords include: $f"
+done
+
+Related resources
+
+- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1063.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1063.json
index 534ce1e..6e9c80f 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1063.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1063.json
@@ -1,5 +1,5 @@
{
- "title": "You need a line feed or semicolon before the 'do'.",
+ "title": "You need a line feed or semicolon before the do.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1064.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1064.html
index b09ca5f..0c0241e 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1064.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1064.html
@@ -1,12 +1,12 @@
-Expected a { to open the function definition.
+Expected a { to open the function definition.
Problematic code
-foo() {
+foo() {
echo "hello world"
}
foo()
Correct code
-foo() {
+foo() {
echo "hello world"
}
foo
@@ -18,7 +18,7 @@ Rationale
If you are trying to do something else, look up the syntax for what you are trying to do.
Exceptions
POSIX allows the body of a function to be any compound command, e.g. foo() for i; do :; done. Since this usage is rare, ShellCheck intentionally requires the body to be { ..; } (or ( ..; )):
-foo() {
+foo() {
for i; do :; done
}
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1065.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1065.html
index c11ad7a..fb6db94 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1065.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1065.html
@@ -1,12 +1,12 @@
-Trying to declare parameters? Don't. Use () and refer to params as $1, $2..
+Trying to declare parameters? Don't. Use () and refer to params as $1, $2, …
Problematic code
-foo(input) {
+foo(input) {
echo "$input"
}
foo("hello world");
Correct code
-foo() {
+foo() {
echo "$1"
}
foo "hello world"
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1065.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1065.json
index 9481663..b628e22 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1065.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1065.json
@@ -1,5 +1,5 @@
{
- "title": "Trying to declare parameters? Don't. Use () and refer to params as $1, $2..",
+ "title": "Trying to declare parameters? Don't. Use () and refer to params as $1, $2, \u2026",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1066.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1066.html
index b7c6ef2..463cab2 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1066.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1066.html
@@ -1,17 +1,17 @@
-Don't use $ on the left side of assignments.
+Don't use $ on the left side of assignments.
Problematic code
-$greeting="Hello World"
+$greeting="Hello World"
Correct code
-greeting="Hello World"
+greeting="Hello World"
Alternatively, if the goal was to assign to a variable whose name is in another variable (indirection), use declare:
-name=foo
+name=foo
declare "$name=hello world"
echo "$foo"
Or if you actually wanted to compare the value, use a test expression:
-if [ "$greeting" = "hello world" ]
+if [ "$greeting" = "hello world" ]
then
echo "Programmer, I presume?"
fi
@@ -19,4 +19,4 @@ Correct code
Rationale
Unlike Perl or PHP, $ is not used when assigning to a variable.
Exceptions
-If you wanted to
+None.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1067.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1067.html
index af51536..eb18279 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1067.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1067.html
@@ -1,35 +1,35 @@
-For indirection, use arrays, declare "var$n=value", or (for sh) read/eval
+For indirection, use arrays, declare "var$n=value", or (for sh) read/eval
Problematic code
-n=1
+n=1
var$n="hello"
Correct code
For integer indexing in ksh/bash, consider using an indexed array:
-n=1
+n=1
var[n]="hello"
echo "${var[n]}"
For string indexing in ksh/bash, use an associative array:
-typeset -A var
+typeset -A var
n="greeting"
var[$n]="hello"
echo "${var[$n]}"
If you actually need a variable with the constructed name in bash, use declare:
-n="Foo"
+n="Foo"
declare "var$n=42"
echo "$varFoo"
For sh, with single line contents, consider read:
-n="Foo"
+n="Foo"
read -r "var$n" << EOF
hello
EOF
echo "$varFoo"
or with careful escaping, eval:
-n=Foo
-eval "var$n='hello'"
+n=Foo
+eval "var$n='hello'"
echo "$varFoo"
Rationale
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1067.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1067.json
index c68b195..d60dff8 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1067.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1067.json
@@ -1,5 +1,5 @@
{
- "title": "For indirection, use arrays, declare 'var$n=value', or (for sh) read\/eval",
+ "title": "For indirection, use arrays, declare "var$n=value", or (for sh) read\/eval",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1068.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1068.html
index 257f03b..a7acb68 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1068.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1068.html
@@ -1,11 +1,11 @@
-Don't put spaces around the = in assignments.
+Don't put spaces around the = in assignments.
Problematic code
-foo = 42
+foo = 42
Correct code
-foo=42
+foo=42
Rationale
Shells are space sensitive. foo=42 means to assign 42 to the variable foo. foo = 42 means to run a command named foo, and pass = as $1 and 42 as $2.
Exceptions
-If you actually wanted to run a command named foo and provide = as the first argument, simply quote it to make ShellCheck be quiet: foo "=" 42.
+If you actually wanted to run a command named foo and provide = as the first argument, simply quote it to make ShellCheck be quiet: foo "=" 42.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1069.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1069.html
index 49dd9ca..bac71b8 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1069.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1069.html
@@ -1,10 +1,10 @@
-You need a space before the [.
+You need a space before the [.
Problematic code
-if[ -e file ]
+if[ -e file ]
then echo "exists"; fi
Correct code
-if [ -e file ]
+if [ -e file ]
then echo "exists"; fi
Rationale
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1070.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1070.html
index bd97bd9..7f359ac 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1070.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1070.html
@@ -1,5 +1,5 @@
Parsing stopped here. Mismatched keywords or invalid parentheses?
Rationale
-Shellcheck found a syntax error at the indicated location. Barring a bug in Shellcheck itself, your shell will also crash with a syntax error at the same location, so you cannot ignore this check.
+ShellCheck found a syntax error at the indicated location. Barring a bug in ShellCheck itself, your shell will also crash with a syntax error at the same location, so you cannot ignore this check.
Exceptions
None.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1071.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1071.html
index 0dba38f..3f52682 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1071.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1071.html
@@ -1,6 +1,6 @@
ShellCheck only supports sh/bash/dash/ksh scripts. Sorry!
Problematic code
-#!/usr/bin/python
+#!/usr/bin/python
print "Hello"
Rationale
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1072.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1072.html
index c9ed6de..d543302 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1072.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1072.html
@@ -1,3 +1,13 @@
Unexpected ..
Note: There is a known bug in the current version when directives appear within then clauses of if blocks that causes Shellcheck to report SC1072 on otherwise valid code. Avoid using directives within then clauses - instead place them at the top of the if block or another enclosing block. This is fixed on the online version and the next release.
See Parser Error.
+This error can also occur with an incomplete shellcheck directive like # shellcheck disable instead of # shellcheck disable=all
+Problematic code
+# shellcheck disable
+echo stuff that shellcheck up to at least v0.10.0 will not even see because of the incorrect directive above
+
+Correct code
+# shellcheck disable=all
+echo stuff that shellcheck will correctly ignore entirely
+
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1074.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1074.html
index 7d41407..24d46e8 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1074.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1074.html
@@ -1,6 +1,6 @@
Did you forget the ;; after the previous case item?
Problematic code
-while getoptions f option
+while getoptions f option
do
case "${options}"
in
@@ -10,11 +10,11 @@ Problematic code
done
Correct code
-while getoptions f option
+while getoptions f option
do
case "${options}"
in
- f) FTR="${ARG}"
+ f) FTR="${ARG}";;
\?) exit;;
esac
done
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1075.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1075.html
index ae87ddf..ce7de95 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1075.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1075.html
@@ -1,15 +1,16 @@
-Use 'elif' instead of 'else if'.
+Use elif instead of else if.
Problematic code
-if [ "$#" -eq 0 ]
+if [ "$#" -eq 0 ]
then
echo "Usage: ..."
else if [ "$#" -lt 2 ]
then
echo "Missing operand"
fi
+
Correct code
-if [ "$#" -eq 0 ]
+if [ "$#" -eq 0 ]
then
echo "Usage: ..."
elif [ "$#" -lt 2 ]
@@ -22,7 +23,7 @@ Rationale
Exceptions
else if is a valid (though confusing) way of nesting an if statement in a parent's else. If this is your intention, consider using canonical formatting by putting a linefeed between else and if.
This does not change the behavior of the script, but merely makes it more obvious to ShellCheck (and other humans) that you didn't expect the else if to behave the way it does in C. Alternatively, you can [[ignore]] it with no ill effects.
-
+
if x
then
echo "x"
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1075.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1075.json
index 478c93f..a95afbe 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1075.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1075.json
@@ -1,5 +1,5 @@
{
- "title": "Use 'elif' instead of 'else if'.",
+ "title": "Use elif instead of else if.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1076.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1076.html
index cb1e54f..a3a857e 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1076.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1076.html
@@ -1 +1,16 @@
-Trying to do math? Use e.g. [ $((i/2+7)) -ge 18 ] or [[ $((i/2+7)) -ge 18 ]].
\ No newline at end of file
+Trying to do math? Use e.g. [ $((i/2+7)) -ge 18 ].
+Problematic code
+[ i / 2 + 7 -ge 18 ]
+
+Correct code
+[ $((i / 2 + 7)) -ge 18 ]
+
+Rationale
+ShellCheck found a loose +*/% in a test statement. This usually happens when trying to do arithmetic in a condition, but without using the arithmetic expansion construct $((expression)).
+In C, if (a+b == c) is perfectly fine, but in sh this must be written to first expand the arithmetic operation like if [ $((a+b)) = c ].
+Exceptions
+None.
+Related resources
+
+- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1076.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1076.json
index b368c4c..45e4878 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1076.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1076.json
@@ -1,5 +1,5 @@
{
- "title": "Trying to do math? Use e.g. [ $((i\/2+7)) -ge 18 ] or [[ $((i\/2+7)) -ge 18 ]].",
+ "title": "Trying to do math? Use e.g. [ $((i\/2+7)) -ge 18 ].",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1077.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1077.html
index 837cf74..fa60f67 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1077.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1077.html
@@ -1,9 +1,9 @@
-For command expansion, the tick should slant left (` vs ´).
+For command expansion, the tick should slant left (` vs ´).
Problematic code
-echo "Your username is ´whoami´"
+echo "Your username is ´whoami´"
Correct code
-echo "Your username is $(whoami)" # Preferred
+echo "Your username is $(whoami)" # Preferred
echo "Your username is `whoami`" # Deprecated, will give [SC2006]
Rationale
@@ -11,9 +11,9 @@ Rationale
Backticks start command expansions, while forward ticks are literal. To help spot bugs, ShellCheck parses backticks and forward ticks interchangeably.
Exceptions
If you want to write out literal forward ticks, such as fancyful ascii quotation marks:
-echo "``Proprietary software is an injustice.´´ - Richard Stallman"
+echo "``Proprietary software is an injustice.´´ - Richard Stallman"
use single quotes instead:
-echo '``Proprietary software is an injustice.´´ - Richard Stallman'
+echo '``Proprietary software is an injustice.´´ - Richard Stallman'
To nest forward ticks in command expansion, use $(..) instead of `..`.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1078.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1078.html
index 7be10a9..8203865 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1078.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1078.html
@@ -1,10 +1,10 @@
-Did you forget to close this double quoted string?
+Did you forget to close this double-quoted string?
Problematic code
-greeting="hello
+greeting="hello
target="world"
Correct code
-greeting="hello"
+greeting="hello"
target="world"
Rationale
@@ -12,11 +12,11 @@ Rationale
ShellCheck warns when it detects multi-line double quoted, single quoted or backticked strings when the character that follows it looks out of place (and gives a companion warning [[SC1079]] at that spot).
Exceptions
If you do want a multiline variable, just make sure the character after it is a quote, space or line feed.
-var='multiline
-'value
+var='multiline
+'value
can be rewritten for readability and to remove the warning:
-var='multiline
-value'
+var='multiline
+value'
As always `..` should be rewritten to $(..).
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1078.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1078.json
index ce7a551..c6bf65e 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1078.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1078.json
@@ -1,5 +1,5 @@
{
- "title": "Did you forget to close this double quoted string?",
+ "title": "Did you forget to close this double-quoted string?",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1080.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1080.html
index bf54ac7..40bd13d 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1080.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1080.html
@@ -1 +1,17 @@
-You need \ before line feeds to break lines in [ ].
\ No newline at end of file
+You need \ before line feeds to break lines in [ ].
+Problematic code
+[ "$filename" =
+ "$otherfile" ]
+
+Correct code
+[ "$filename" = \
+ "$otherfile" ]
+
+Rationale
+Bash/ksh [[ ]]] can include line breaks anywhere, but [ ] requires that you escape them. If you are writing a multi-line [ .. ] statement, make sure to include these escapes. If the [ ] is supposed to be on a single line, make sure the ] is there.
+Exceptions
+None
+Related resources
+
+- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1081.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1081.html
index 0c44e48..95dc782 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1081.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1081.html
@@ -1,12 +1,12 @@
-Scripts are case sensitive. Use 'if', not 'If'.
+Scripts are case-sensitive. Use if, not If.
Problematic code
-If true
+If true
Then
echo "hello"
Fi
Correct code
-if true
+if true
then
echo "hello"
fi
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1081.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1081.json
index 0eb572e..64d4f8d 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1081.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1081.json
@@ -1,5 +1,5 @@
{
- "title": "Scripts are case sensitive. Use 'if', not 'If'.",
+ "title": "Scripts are case-sensitive. Use if, not If.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1082.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1082.html
index 1742643..b289aac 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1082.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1082.html
@@ -1,9 +1,9 @@
-This file has a UTF-8 BOM. Remove it with: LC_CTYPE=C sed '1s/^...//' < yourscript .
+This file has a UTF-8 BOM. Remove it with: LC_CTYPE=C sed '1s/^...//' < yourscript.
Problematic code
This is an encoding error that can't be seen in the script itself, but cat -v will show three bytes of garbage at the start of the file:
$ cat -v file
M-oM-;M-?#!/bin/bash
-echo "hello world"
+echo "hello world"
Correct code
The code is correct when this garbage does not appear.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1082.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1082.json
index 6bc4ec0..6c8507b 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1082.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1082.json
@@ -1,5 +1,5 @@
{
- "title": "This file has a UTF-8 BOM. Remove it with: LC_CTYPE=C sed '1s\/^...\/\/' < yourscript .",
+ "title": "This file has a UTF-8 BOM. Remove it with: LC_CTYPE=C sed '1s\/^...\/\/' < yourscript.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1083.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1083.html
index 887e6c7..3ce9bbe 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1083.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1083.html
@@ -1,15 +1,15 @@
This {/} is literal. Check if ; is missing or quote the expression.
Problematic code
-rmf() { rm -f "$@" }
+rmf() { rm -f "$@" }
or
-eval echo \${foo}
+eval echo \${foo}
Correct code
-rmf() { rm -f "$@"; }
+rmf() { rm -f "$@"; }
and
-eval "echo \${foo}"
+eval "echo \${foo}"
Rationale
Curly brackets are normally used as syntax in parameter expansion, command grouping and brace expansion.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1084.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1084.html
index 03d9f09..e693f63 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1084.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1084.html
@@ -1,10 +1,10 @@
-Use #!, not !#, for the shebang.
+Use #!, not !#, for the shebang.
Problematic code
-!#/bin/sh
+!#/bin/sh
echo "Hello World"
Correct code
-#!/bin/sh
+#!/bin/sh
echo "Hello World"
Rationale
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1086.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1086.html
index 0bafe49..119aecf 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1086.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1086.html
@@ -1,12 +1,12 @@
-Don't use $ on the iterator name in for loops.
+Don't use $ on the iterator name in for loops.
Problematic code
-for $var in *
+for $var in *
do
echo "$var"
done
Correct code
-for var in *
+for var in *
do
echo "$var"
done
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1087.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1087.html
index bf0e284..f41b352 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1087.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1087.html
@@ -1,9 +1,9 @@
-"Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet)."
+Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet).
Problematic code
-echo "$array[@]"
+echo "$array[@]"
Correct code
-echo "${array[@]}"
+echo "${array[@]}"
Rationale
Some languages use the syntax $array[index] to access an index of an arrays, but a shell will interpret this as $array followed by the unrelated literal string (or glob) [index].
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1087.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1087.json
index 62b529a..37039c9 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1087.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1087.json
@@ -1,5 +1,5 @@
{
- "title": "'Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet).'",
+ "title": "Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet).",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1088.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1088.html
index 693baa8..5a9cf08 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1088.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1088.html
@@ -1,24 +1,27 @@
Parsing stopped here. Invalid use of parentheses?
Problematic code
-grep ^(.*)\1$ file
+grep ^(.*)\1$ file
or
-var=myfunction(value)
+var=myfunction(value)
Correct code
-grep '^(.*)\1$' file
+grep '^(.*)\1$' file
or
-var=$(myfunction value)
+var=$(myfunction value)
Rationale
Parentheses are shell syntax and must be used correctly.
For commands that expect literal parentheses, such as grep or find, the parentheses need to be quoted or escaped so the shell does not interpret them, but instead passes them to the command.
For shell syntax, the shell does not use them the way most other languages do, so avoid guessing at syntax based on previous experience. In particular:
-- Parentheses are NOT used to call functions.
-- Parentheses are NOT used to group expressions, except in arithmetic contexts.
-- Parentheses are NOT used in conditional statements or loops.
+Parentheses are NOT used to call functions.
+
+Parentheses are NOT used to group expressions, except in arithmetic contexts.
+
+Parentheses are NOT used in conditional statements or loops.
+
Parentheses are used differently in different contexts. ( .. ), $( .. ), $(( .. )) and var=(..) are completely separate and independent structures with different meanings, and can not be broken down into operations on expressions in parentheses.
In C-like languages, ++ can't be broken down into two + operations, so you can't e.g. use + + or +(+). In the same way, all of the above are completely unrelated so that you can't do $(1+1) or $( (1+1) ) in place of $(( 1+1 )).
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1089.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1089.html
index 15f8c86..685ddd8 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1089.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1089.html
@@ -1,13 +1,13 @@
Parsing stopped here. Is this keyword correctly matched up?
Problematic code
-
if true
+if true
then
echo hello
fi
fi
Correct code
-if true
+if true
then
echo hello
fi
@@ -15,7 +15,7 @@ Correct code
Rationale
This error is typically seen when there are too many fi, done or esacs, or when there's a do or then without a corresponding while, for or if. This is often due to deleting a loop or conditional statement but not its terminator.
In some cases, it can even be caused by bad quoting:
-var="foo
+var="foo
if [[ $var = "bar ]
then
echo true
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1090.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1090.html
index 7cba88a..1431f92 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1090.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1090.html
@@ -1,14 +1,14 @@
-Can't follow non-constant source. Use a directive to specify location.
+Can't follow non-constant source. Use a directive to specify location
Problematic code
-. "${util_path}"
+. "${util_path}"
Correct code
-# shellcheck source=src/util.sh
+# shellcheck source=src/util.sh
. "${util_path}"
Rationale
ShellCheck is not able to include sourced files from paths that are determined at runtime. The file will not be read, potentially resulting in warnings about unassigned variables and similar.
Use a [[Directive]] to point shellcheck to a fixed location it can read instead.
-ShellCheck v0.7.2+ will strip a single expansion followed by a slash, e.g. ${var}/util.sh or $(dirname "${BASH_SOURCE[0]}")/util.sh, and treat them as ./util.sh. This allowing the use of source-path directives or -P flags to specify the a location.
+ShellCheck v0.7.2+ will strip a single expansion followed by a slash, e.g. ${var}/util.sh or $(dirname "${BASH_SOURCE[0]}")/util.sh, and treat them as ./util.sh. This allows the use of source-path directives or -P flags to specify the location.
Exceptions
If you don't care that ShellCheck is unable to account for the file, specify # shellcheck source=/dev/null.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1090.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1090.json
index 152d65a..43ae46c 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1090.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1090.json
@@ -1,5 +1,5 @@
{
- "title": "Can't follow non-constant source. Use a directive to specify location.",
+ "title": "Can't follow non-constant source. Use a directive to specify location",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1091.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1091.html
index 9fbe4f7..627ead7 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1091.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1091.html
@@ -1,21 +1,27 @@
Not following: (error message here)
Reasons include: file not found, no permissions, not included on the command line, not allowing shellcheck to follow files with -x, etc.
Problematic code
-source somefile
+source somefile
Correct code
In case you have access to the file, e.g. if it is included in your source code repository:
-# shellcheck source=somefile
+# shellcheck source=somefile
source somefile
In case you do not have access to the file:
-# shellcheck source=/dev/null
+# shellcheck source=/dev/null
source somefile
Rationale
ShellCheck, for whichever reason, is not able to access the source file.
-This could be because you did not include it on the command line, did not use shellcheck -x to allow following other files, don't have permissions or a variety of other problems.
+This could be because:
+
+- you did not include it on the command line,
+- did not use
shellcheck -x (or specified external-sources=true in the [[.shellcheckrc|Directive#external-sources]]) to allow following other files
+- don't have permissions, or
+- a variety of other problems.
+
Feel free to ignore the error with a [[directive]].
Exceptions
-ShellCheck is unable to follow dynamic paths, such as source "$somedir/file". For these cases, see [[SC1090: Can't follow non-constant source. Use a directive to specify location|SC1090]] instead. You may be seeing SC1091 because ShellCheck tried to be helpful and strip a leading dynamic path element as described on that page.
+ShellCheck is unable to follow dynamic paths, such as source "$somedir/file". For these cases, see SC1090: Can't follow non-constant source. Use a directive to specify location instead. You may be seeing SC1091 because ShellCheck tried to be helpful and strip a leading dynamic path element as described on that page.
If you're fine with it, ignore the message with a [[directive]].
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1092.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1092.html
index 9b90093..0e6d89b 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1092.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1092.html
@@ -1 +1,13 @@
-Stopping at 100 'source' frames :O
\ No newline at end of file
+Stopping at 100 source frames :O
+Problematic code
+An initial file sourcing a second file, which in turn sources a third file, which in turn sources a fourth file, ...., which in turn sources a 100th file.
+Correct code
+Anything but that.
+Rationale
+ShellCheck found a chain of 100+ files sourcing each other. It assumed there must be some internal bug, so it stopped.
+Exceptions
+If this is intentional, you can cosmetically [[ignore]] this message.
+Related resources
+
+- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1092.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1092.json
index ba5e7a5..2920c18 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1092.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1092.json
@@ -1,5 +1,5 @@
{
- "title": "Stopping at 100 'source' frames :O",
+ "title": "Stopping at 100 source frames :O",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1094.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1094.html
index 08ee96c..542a8e8 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1094.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1094.html
@@ -1,9 +1,9 @@
Parsing of sourced file failed. Ignoring it.
Problematic code
-source mylib
+source mylib
Correct code
-# shellcheck disable=SC1094
+# shellcheck disable=SC1094
source mylib
(or fix mylib)
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1095.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1095.html
index 3d3d95b..5774667 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1095.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1095.html
@@ -1,17 +1,17 @@
You need a space or linefeed between the function name and body.
Problematic code
-function foo{
+function foo{
echo "hello world"
}
Correct code
Prefer POSIX syntax:
-foo() {
+foo() {
echo "hello world"
}
Alternatively, add the missing space between function name and opening {:
-# v-- Here
+# v-- Here
function foo {
echo "hello world"
}
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1097.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1097.html
index 52392f7..765b495 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1097.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1097.html
@@ -1,13 +1,13 @@
-Unexpected ==. For assignment, use =. For comparison, use [/[[.
+Unexpected ==. For assignment, use =. For comparison, use [/[[.
Problematic code
-var==value
+var==value
Correct code
Assignment:
-var=value
+var=value
Comparison:
-[ "$var" = value ]
+[ "$var" = value ]
Rationale
ShellCheck has noticed that you're using == in an unexpected way. The two most common reasons for this is:
@@ -19,5 +19,5 @@ Rationale
Exceptions
If you wanted to assign a literal equals sign, use quotes to make this clear:
-var="=sum(A1:A10)"
+var="=sum(A1:A10)"
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1098.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1098.html
index 8f6a67c..60e6707 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1098.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1098.html
@@ -1,9 +1,9 @@
-Quote/escape special characters when using eval, e.g. eval "a=(b)".
+Quote/escape special characters when using eval, e.g. eval "a=(b)".
Problematic code
-eval $var=(a b)
+eval $var=(a b)
Correct code
-eval "$var=(a b)"
+eval "$var=(a b)"
Rationale
Shells differ widely in how they handle unescaped parentheses in eval expressions.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1098.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1098.json
index 02d1c32..1d2d2cc 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1098.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1098.json
@@ -1,5 +1,5 @@
{
- "title": "Quote\/escape special characters when using eval, e.g. eval 'a=(b)'.",
+ "title": "Quote\/escape special characters when using eval, e.g. eval "a=(b)".",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1099.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1099.html
index 1c7417d..035fa7a 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1099.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1099.html
@@ -1,12 +1,12 @@
-You need a space before the #.
+You need a space before the #.
Problematic code
-while sleep 1
+while sleep 1
do# show time
date
done
Correct code
-while sleep 1
+while sleep 1
do # show time
date
done
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1100.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1100.html
index 9d3bdfb..a008f67 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1100.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1100.html
@@ -1,9 +1,9 @@
-This is a unicode dash. Delete and retype as ASCII minus.
+This is a Unicode dash. Delete and retype as ASCII minus.
Problematic code
-[[ 3 –gt 2 ]] # Uses unicode en-dash character
+[[ 3 –gt 2 ]] # Uses unicode en-dash character
Correct code
-[[ 3 -gt 2 ]] # Uses regular ASCII hyphen-minus character
+[[ 3 -gt 2 ]] # Uses regular ASCII hyphen-minus character
Rationale
A character that looks similar to - has made its way into your code. This is usually due to copy-pasting from blogs and other websites that formatted code as text, replacing the ASCII hyphen-minus with a Unicode dash character.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1100.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1100.json
index 323c6a6..a68e13d 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1100.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1100.json
@@ -1,5 +1,5 @@
{
- "title": "This is a unicode dash. Delete and retype as ASCII minus.",
+ "title": "This is a Unicode dash. Delete and retype as ASCII minus.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1101.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1101.html
index 2fe5afb..f97057e 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1101.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1101.html
@@ -1,11 +1,11 @@
-Delete trailing spaces after \ to break line (or use quotes for literal space).
+Delete trailing spaces after \ to break line (or use quotes for literal space).
Problematic code
-# There are spaces after the backslash:
+# There are spaces after the backslash:
echo hello \
world
Correct code
-# No spaces after the backslash:
+# No spaces after the backslash:
echo hello \
world
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1102.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1102.html
index c71e9ba..2f4cc4d 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1102.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1102.html
@@ -1,9 +1,9 @@
-Shells disambiguate $(( differently or not at all. For $(command substition), add space after $( . For $((arithmetics)), fix parsing errors.
+Shells disambiguate $(( differently or not at all. For $(command substitution), add space after $( . For $((arithmetics)), fix parsing errors.
Problematic code
-echo "$((cmd "$@") 2>&1)"
+echo "$((cmd "$@") 2>&1)"
Correct code
-echo "$( (cmd "$@") 2>&1)"
+echo "$( (cmd "$@") 2>&1)"
Rationale
You appear to be using $(( with two (or more) parentheses in a row, where the first $( should open a subshell.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1102.json b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1102.json
index e10fec2..33991ec 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1102.json
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1102.json
@@ -1,5 +1,5 @@
{
- "title": "Shells disambiguate $(( differently or not at all. For $(command substition), add space after $( . For $((arithmetics)), fix parsing errors.",
+ "title": "Shells disambiguate $(( differently or not at all. For $(command substitution), add space after $( . For $((arithmetics)), fix parsing errors.",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1103.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1103.html
index 18e74f6..8e731f8 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1103.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1103.html
@@ -1 +1,30 @@
-This shell type is unknown. Use e.g. sh or bash.
\ No newline at end of file
+This shell type is unknown. Use e.g. sh or bash.
+Problematic code
+# shellcheck shell=zsh
+export PAGER=less
+
+Correct code
+Any supported shell on the shebang or the -s option
+# shellcheck shell=sh
+export PAGER=less
+
+Rationale
+Shellcheck only supports a specific range of shell dialects, there are many more applications providing shell like experiences and some of them look and feel like POSIX shell or bash but does not support the same commands.
+One notable unsupported shell type is zsh, see issue #809 about supporting zsh - some efforts have been done in the past.
+Exceptions
+The supported shell types are listed in the help context, at the moment these are
+
+- sh
+- bash
+- dash
+- ksh
+
+Related resources
+
+- Similar rules
+- [[SC1008]] - unrecognized shebang
+- [[SC1071]] - unsupported shebang
+
+
+- [[Documentation for shell directive|Directive#shell]]
+
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1104.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1104.html
index e12805e..f7dd362 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1104.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1104.html
@@ -1,14 +1,14 @@
-Use #!, not just !, for the shebang.
+Use #!, not just !, for the shebang.
Problematic code
-!/bin/sh
+!/bin/sh
echo "Hello"
Correct code
-#!/bin/sh
+#!/bin/sh
echo "Hello"
Rationale
You appear to be specifying an interpreter in a shebang, but it's missing the hash part. The shebang must always start with #!.
-Even the name "shebang" itself comes from "hash" (#) + "bang" (!).
+Even the name "shebang" itself comes from "hash" (#) + "bang" (!).
Exceptions
None.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1105.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1105.html
index 02de71d..8e1c347 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1105.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1105.html
@@ -1,2 +1,2 @@
-Shells disambiguate (( differently or not at all. If the first ( should start a subshell, add a space after it.
+Shells disambiguate (( differently or not at all. If the first ( should start a subshell, add a space after it.
See [[SC1102]], the similar warning for ambiguous $((.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1106.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1106.html
index 030e5e6..1c92a23 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1106.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1106.html
@@ -1,20 +1,20 @@
In arithmetic contexts, use < instead of -lt
Similarly, > instead of -gt, <= instead of -le, >= instead of -ge, == instead of -eq, != instead of -ne.
Problematic code
-if (( 2 -lt 3 ))
+if (( 2 -lt 3 ))
then
echo "True"
fi
Correct code
-if (( 2 < 3 ))
+if (( 2 < 3 ))
then
echo "True"
fi
Rationale
The comparators -lt, -ge, -eq and friends are flags for the test command aka [. You are instead using it in an arithmetic context, such as (( .. )) or $(( .. )), where you should be using <, >=, == etc instead.
-In arithmetic contexts, -lt is simply interpreted as "subtract the value of $lt", which is clearly not the intention.
+In arithmetic contexts, -lt is simply interpreted as "subtract the value of $lt", which is clearly not the intention.
Exceptions
If you do want to subtract $lt you can add a space to make this clear to ShellCheck: echo $((3 - lt))
Related resources
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1107.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1107.html
index 556b05b..a006ce4 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1107.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1107.html
@@ -1,6 +1,6 @@
This directive is unknown. It will be ignored.
Problematic code
-# shellcheck foobar=baz
+# shellcheck foobar=baz
echo "Hello World"
Correct code
@@ -14,7 +14,7 @@ Exceptions
# shellcheck disable=SC1107
{
# shellcheck unrecognized=directive
- echo "Hello World"
+ echo "Hello World"
}
Before 0.4.5, unrecognized directives are considered parse errors.
diff --git a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1108.html b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1108.html
index bb66044..3369742 100644
--- a/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1108.html
+++ b/src/main/resources/org/sonar/l10n/shellcheck/rules/shellcheck/SC1108.html
@@ -1,12 +1,12 @@
-You need a space before and after the = .
+You need a space before and after the = .
Problematic code
-[ "$var"= 2 ]
+[ "$var"= 2 ]
Correct code
-[ "$var" = 2 ]
+