Moved to list.....
On 3/22/21 1:41 PM, Bruce Dubbs wrote:
On 3/22/21 11:54 AM, Scott Andrews wrote:
On 3/22/21 12:25 PM, Bruce Dubbs wrote:
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.
But it doesn't hurt to escape them either.
\n is a token that means carriage return and linefeed
Exactly. The script is being built up and then used with 'echo -e $MSG'
If I use '\n' it does th right thing. If I use '\\n' it prints the
backslash which I do not want.
Actually it doesn't..............
Test-rc.sh: Begin Run: print_error_msg
***** [
FAIL ]
You should not be reading this error message.
It means that an unforeseen error took place in
/etc/rc.d/rc3.d/S80ntpd,
which exited with a return value of 1.
If you're able to track this error down to a bug in one of the
files provided by the HBL book
Please be so kind to inform us at scott.andr...@columbus.rr.com.
***** [
FAIL ]
Press Enter to continue...
cat bootlog
Mar 22 16:30:55 -04:00 scott.example.org FAIL
Mar 22 16:30:55 -04:00 scott.example.org
You should not be reading this error message.
It means that an unforeseen error took place in
/etc/rc.d/rc3.d/S80ntpd,
which exited with a return value of 1.
If you're able to track this error down to a bug in one of the
files provided by the HBL book
Please be so kind to inform us at scott.andr...@columbus.rr.com.
FAIL
Code is not in proper order, cut and pasted
#!/bin/bash --posix
set -o errexit # exit if error...insurance
set -o nounset # exit if variable not initalized
set +h # disable hashall
# prints error message to screen and logs to
# inputs: filespec
# returns: nothing
function print_error_msg {
local msg=""
log_failure_msg ""
msg+="${FAILURE}\\n${BMPREFIX}You should not be reading this error
message.\\n"
msg+="${BMPREFIX}It means that an unforeseen error took place in\\n"
msg+="${BMPREFIX}${1},\\n"
msg+="${BMPREFIX}which exited with a return value of
${error_value}.\\n"
msg+="${BMPREFIX}If you're able to track this error down to a bug
in one of the\\n"
msg+="${BMPREFIX}files provided by the ${DISTRO_MINI} book\\n"
msg+="${BMPREFIX}Please be so kind to inform us at
${DISTRO_CONTACT}.\\n"
log_failure_msg "${msg}"
echo "Press Enter to continue..." # removes prompt from boot.log
wait_for_user
}
_begin_run print_error_msg
BOOTLOG=${BOOTLOG:-"./bootlog"}
rm -f "${BOOTLOG}"
error_value=1;print_error_msg "/etc/rc.d/rc3.d/S80ntpd"
_end_run print_error_msg
#####################################
# log_failure_msg()
# Usage: log_failure_msg ["message"]
# Purpose: Print a failure status message to the screen and
# a boot log file.
# Inputs: ${1} - Message
# Return values: Not used
#####################################
function log_failure_msg {
local logmessage
/bin/echo -n -e "${BMPREFIX}${1}"
/bin/echo -e
"${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}"
# Strip non-printable characters from log file
logmessage=$(/bin/echo "${1}" | /bin/sed 's/\\\033[^a-zA-Z]*.//g')
timespec
/bin/echo -e "${STAMP} ${logmessage} FAIL" >> "${BOOTLOG}"
return 0
}
BTW here is a part of init-functions that could be considered incorrect
## Measurements for positioning result messages
COL=$((COLUMNS - 8))
WCOL=$((COL - 2))
## Set Cursor Position Commands, used via echo
SET_COL="\\033[${COL}G" # at the $COL char
CURS_ZERO="\\033[0G"
Check it against what is in the latest version.
Yes I have already tested it
$ ./Test-rc.sh
POSIX: y
COLUMNS: 80
COL: 72
WCOL: 70
# Begin Test code
PRGNAME=${0##*/} # script name minus the path
echo "POSIX: ${POSIXLY_CORRECT}"
echo "COLUMNS: ${COLUMNS}"
echo "COL: ${COL}"
echo "WCOL: ${WCOL}"
See above for SET_COL and CURS_ZERO testing.....
And shellcheck is quite correct, if there
Not for our usage.
Yes for all usages.
Show me an example of where shellcheck is not correct and causes the
boot scripts to fail or error.
I have found it to work when run upon all the scripts/sourced scripts.
You may have to correct a couple of things but the result works
I am rewriting the boot init files to a standard.
What standard?
The standard that others seem to be using, or picking up.
It would do well to have a "lint" of some kind before releasing a script
onto the horde.
If a lint is available for use, I use it or run it on what ever project
I am wroking on.
shellcheck and rpmlint are two that comes to mind.
That makes them consistent and less likely to have errors/issues.
OK, We will consider what you contribute.
This post was about possible syntax errors, not shell scripts not
working properly.
Interesting. Doesn't a syntax error imply something not working
properly? Please don't infer that a style difference is an error.
When the scripts were first written, the emphasis beyond working was
readability. They were always considered to be in a closed system
where they did not have arbitrary inputs.
syntax errors and logic errors are two different animals. Just like
runtime errors.
Yes I have found that the boot scripts do indeed do not work properly
in some cases.
What are those cases?
-- Bruce
Does not work with swap partitions.
Brings up all IFACES on restarting as in /etc/init.d/network restart
No way to disable a /etc/sysconfig/ifconfig.* file without moving or
renaming it.
clock fails if the hardware does not contain a hardware clock.
I have others but this is just from what I recall at the moment as I
have not finished with init-functions and rc
--
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