On 3/22/21 10:44 AM, Scott Andrews wrote:

Syntax errors found in /etc/init.d/rc...

Not errors, but someone's preferences.  For instance all the
'Prefer explicit escaping: "\\n"' issues are wrong.  The page
https://github.com/koalaman/shellcheck/wiki/SC1001 says:

Rationale:

You have escaped something that has no special meaning when escaped. The backslash will be simply be ignored.

is not true in these cases.  A \n certainly does have a special meaning.

----

Looking at https://github.com/koalaman/shellcheck/wiki/SC1091 it appears that you are not running shellcheck properly. It appears that you need to specify disable=SC1091.

----

The thing I did notice is the inconsistency between "." and source

. /lib/lsb/init-functions
[ -r /etc/sysconfig/rc.site ] && source /etc/sysconfig/rc.site

However, the header line is #!/bin/bash and is not an error.

If you really think there is an error, give us an example where the code does not work properly.

  -- Bruce




Found by shellcheck


In rc line 15:
. /lib/lsb/init-functions
^-- SC1091: Not following: /lib/lsb/init-functions was not specified as input (see shellcheck -x).


In rc line 21:
    MSG="FAILURE:\n\nYou should not be reading this error message.\n\n"
                ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".                   ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".
^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".
^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 22:
    MSG="${MSG}It means that an unforeseen error took place in\n"
                                                             ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 23:
    MSG="${MSG}${i},\n"
                   ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 24:
    MSG="${MSG}which exited with a return value of ${error_value}.\n"
^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 26:
   MSG="${MSG}If you're able to track this error down to a bug in one of\n"
^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 27:
    MSG="${MSG}the files provided by the ${DISTRO_MINI} book,\n"
                                                            ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 28:
    MSG="${MSG}please be so kind to inform us at ${DISTRO_CONTACT}.\n"
^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 38:
    if [ ! -f ${i} ]; then
             ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 43:
    if [ ! -x ${i} ]; then
             ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 51:
    if [ -z $interactive ]; then
           ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 52:
       ${1} ${2}
           ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 57:
       read -p "Run ${1} ${2} (Yes/no/continue)? " -n 1 runit
       ^-- SC2162: read without -r will mangle backslashes.


In rc line 63:
             ${i} ${2}
                 ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 73:
             ${i} ${2}
                 ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 84:
[ -r /etc/sysconfig/rc.site ] && source /etc/sysconfig/rc.site
                                 ^-- SC1091: Not following: /etc/sysconfig/rc.site was not specified as input (see shellcheck -x).


In rc line 104:
if [ ! -d /etc/rc.d/rc${runlevel}.d ]; then
                      ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 105:
    log_info_msg "/etc/rc.d/rc${runlevel}.d does not exist.\n"
                                                          ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 109:
if [ "$runlevel" == "6" -o "$runlevel" == "0" ]; then IPROMPT="no"; fi
                        ^-- SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.


In rc line 113:
    [ -r /etc/sysconfig/console ] && source /etc/sysconfig/console
                                    ^-- SC1091: Not following: /etc/sysconfig/console was not specified as input (see shellcheck -x).


In rc line 117:
if [ "${IPROMPT}" == "yes" -a "${runlevel}" == "S" ]; then
                           ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.


In rc line 129:
    wcol=$(( ( ${COLUMNS} - ${wlen} ) / 2 ))
               ^-- SC2004: $/${} is unnecessary on arithmetic variables.
                           ^-- SC2004: $/${} is unnecessary on arithmetic variables.


In rc line 130:
    icol=$(( ( ${COLUMNS} - ${ilen} ) / 2 ))
               ^-- SC2004: $/${} is unnecessary on arithmetic variables.
                           ^-- SC2004: $/${} is unnecessary on arithmetic variables.


In rc line 133:
    echo -e "\n\n"
            ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".               ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 137:
    read -t "${itime}" -n 1 interactive 2>&1 > /dev/null
    ^-- SC2162: read without -r will mangle backslashes.
                                       ^-- SC2069: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).


In rc line 145:
[ -r /run/interactive ] && source /run/interactive
                           ^-- SC1091: Not following: /run/interactive was not specified as input (see shellcheck -x).


In rc line 150:
    for i in $(ls -v /etc/rc.d/rc${runlevel}.d/K* 2> /dev/null)
             ^-- SC2045: Iterating over ls output is fragile. Use globs.
                                ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 159:
       prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
                 ^-- SC2125: Brace expansions and globs are literal in assignments. Quote it or use an array.


In rc line 160:
       sysinit_start=/etc/rc.d/rcS.d/S[0-9][0-9]$suffix
                    ^-- SC2125: Brace expansions and globs are literal in assignments. Quote it or use an array.


In rc line 162:
       if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then
                                ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.


In rc line 163:
          if [ ! -f ${prev_start} -a  ! -f ${sysinit_start} ]; then
                   ^-- SC2086: Double quote to prevent globbing and word splitting.                                  ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.                                           ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 164:
             MSG="WARNING:\n\n${i} can't be "
                         ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".                            ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".


In rc line 173:
       run ${i} stop
           ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 182:
if [ "$runlevel" == "6" -a -n "${FASTBOOT}" ]; then
                        ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.


In rc line 188:
for i in $( ls -v /etc/rc.d/rc${runlevel}.d/S* 2> /dev/null)
          ^-- SC2045: Iterating over ls output is fragile. Use globs.
                              ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 192:
       stop=/etc/rc.d/rc$runlevel.d/K[0-9][0-9]$suffix
           ^-- SC2125: Brace expansions and globs are literal in assignments. Quote it or use an array.


In rc line 193:
       prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
                 ^-- SC2125: Brace expansions and globs are literal in assignments. Quote it or use an array.


In rc line 195:
       [ -f ${prev_start} -a ! -f ${stop} ] && continue
           ^-- SC2086: Double quote to prevent globbing and word splitting.                          ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.                                  ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 206:
          run ${i} stop
             ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 209:
          run ${i} start
             ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 219:
if [ "${runlevel}" == "S" -a "${interactive}" == "i" ]; then
                          ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.


In rc line 226:
if [ "${previous}" == "N" -a  "${runlevel}" != "S" ]; then
                          ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.


In rc line 227:
    cat $BOOTLOG >> /var/log/boot.log
        ^-- SC2086: Double quote to prevent globbing and word splitting.


In rc line 233:
    rm -f $BOOTLOG 2> /dev/null
          ^-- SC2086: Double quote to prevent globbing and word splitting.




--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

http://en.wikipedia.org/wiki/Posting_style

Reply via email to