All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh
@ 2020-07-24 17:12 Andrei Gherzan
  2020-07-24 17:12 ` [PATCH 2/2] initscripts: Fix populate-volatile.sh bug when file/dir exists Andrei Gherzan
  2020-07-25  5:14 ` [OE-core] [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh Khem Raj
  0 siblings, 2 replies; 5+ messages in thread
From: Andrei Gherzan @ 2020-07-24 17:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Andrei Gherzan

Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
---
 .../initscripts-1.0/populate-volatile.sh      | 58 +++++++++----------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index 1c525b71bd..3a265329f0 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -9,10 +9,10 @@
 ### END INIT INFO
 
 # Get ROOT_DIR
-DIRNAME=`dirname $0`
-ROOT_DIR=`echo $DIRNAME | sed -ne 's:/etc/.*::p'`
+DIRNAME="$(dirname "$0")"
+ROOT_DIR="$(echo "$DIRNAME" | sed -ne 's:/etc/.*::p')"
 
-[ -e ${ROOT_DIR}/etc/default/rcS ] && . ${ROOT_DIR}/etc/default/rcS
+[ -e "${ROOT_DIR}/etc/default/rcS" ] && . "${ROOT_DIR}/etc/default/rcS"
 # When running populate-volatile.sh at rootfs time, disable cache.
 [ -n "$ROOT_DIR" ] && VOLATILE_ENABLE_CACHE=no
 # If rootfs is read-only, disable cache.
@@ -46,13 +46,13 @@ create_file() {
 		[ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
 	} || {
 		if [ -z "$ROOT_DIR" ]; then
-			eval $EXEC
+			eval "$EXEC"
 		else
 			# Creating some files at rootfs time may fail and should fail,
 			# but these failures should not be logged to make sure the do_rootfs
 			# process doesn't fail. This does no harm, as this script will
 			# run on target to set up the correct files and directories.
-			eval $EXEC > /dev/null 2>&1
+			eval "$EXEC" > /dev/null 2>&1
 		fi
 	}
 }
@@ -68,11 +68,11 @@ mk_dir() {
 		[ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
 	} || {
 		if [ -z "$ROOT_DIR" ]; then
-			eval $EXEC
+			eval "$EXEC"
 		else
 			# For the same reason with create_file(), failures should
 			# not be logged.
-			eval $EXEC > /dev/null 2>&1
+			eval "$EXEC" > /dev/null 2>&1
 		fi
 	}
 }
@@ -96,11 +96,11 @@ link_file() {
 	test "$VOLATILE_ENABLE_CACHE" = yes && echo "	$EXEC" >> /etc/volatile.cache.build
 
 	if [ -z "$ROOT_DIR" ]; then
-		eval $EXEC
+		eval "$EXEC"
 	else
 		# For the same reason with create_file(), failures should
 		# not be logged.
-		eval $EXEC > /dev/null 2>&1
+		eval "$EXEC" > /dev/null 2>&1
 	fi
 }
 
@@ -117,11 +117,11 @@ check_requirements() {
 	TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
 	TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
 
-	sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/passwd | sort | uniq > "${TMP_DEFINED}"
-	cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 2 > "${TMP_INTERMED}"
+	sed 's@\(^:\)*:.*@\1@' "${ROOT_DIR}/etc/passwd" | sort | uniq > "${TMP_DEFINED}"
+	grep -v "^#" "${CFGFILE}" | cut -s -d " " -f 2 > "${TMP_INTERMED}"
 	cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
-	NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
-	NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
+	NR_DEFINED_USERS="$(wc -l < "${TMP_DEFINED}")"
+	NR_COMBINED_USERS="$(wc -l < "${TMP_COMBINED}")"
 
 	[ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
 		echo "Undefined users:"
@@ -131,12 +131,12 @@ check_requirements() {
 	}
 
 
-	sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/group | sort | uniq > "${TMP_DEFINED}"
-	cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 3 > "${TMP_INTERMED}"
+	sed 's@\(^:\)*:.*@\1@' "${ROOT_DIR}/etc/group" | sort | uniq > "${TMP_DEFINED}"
+	grep -v "^#" "${CFGFILE}" | cut -s -d " " -f 3 > "${TMP_INTERMED}"
 	cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
 
-	NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
-	NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
+	NR_DEFINED_GROUPS="$(wc -l < "${TMP_DEFINED}")"
+	NR_COMBINED_GROUPS="$(wc -l < "${TMP_COMBINED}")"
 
 	[ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
 		echo "Undefined groups:"
@@ -157,13 +157,13 @@ apply_cfgfile() {
 
 	[ "${VERBOSE}" != "no" ] && echo "Applying ${CFGFILE}"
 
-	[ "${SKIP_REQUIREMENTS}" == "yes" ] || check_requirements "${CFGFILE}" || {
+	[ "${SKIP_REQUIREMENTS}" = "yes" ] || check_requirements "${CFGFILE}" || {
 		echo "Skipping ${CFGFILE}"
 		return 1
 	}
 
-	cat ${CFGFILE} | sed 's/#.*//' | \
-	while read TTYPE TUSER TGROUP TMODE TNAME TLTARGET; do
+	sed 's/#.*//' "${CFGFILE}" | \
+	while read -r TTYPE TUSER TGROUP TMODE TNAME TLTARGET; do
 		test -z "${TLTARGET}" && continue
 		TNAME=${ROOT_DIR}${TNAME}
 		[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
@@ -187,9 +187,9 @@ apply_cfgfile() {
 
 		[ -L "${TNAME}" ] && {
 			[ "${VERBOSE}" != "no" ] && echo "Found link."
-			NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'`
-			echo ${NEWNAME} | grep -v "^/" >/dev/null && {
-				TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}"
+			NEWNAME=$(ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/')
+			echo "${NEWNAME}" | grep -v "^/" >/dev/null && {
+				TNAME="$(echo "${TNAME}" | sed -e 's@\(.*\)/.*@\1@')/${NEWNAME}"
 				[ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-."
 			} || {
 				TNAME="${NEWNAME}"
@@ -217,7 +217,7 @@ apply_cfgfile() {
 
 clearcache=0
 exec 9</proc/cmdline
-while read line <&9
+while read -r line <&9
 do
 	case "$line" in
 		*clearcache*)  clearcache=1
@@ -228,11 +228,11 @@ do
 done
 exec 9>&-
 
-if test -e ${ROOT_DIR}/etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
+if test -e "${ROOT_DIR}/etc/volatile.cache" -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
 then
-	sh ${ROOT_DIR}/etc/volatile.cache
+	sh "${ROOT_DIR}/etc/volatile.cache"
 else
-	rm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build
+	rm -f "${ROOT_DIR}/etc/volatile.cache" "${ROOT_DIR}/etc/volatile.cache.build"
 
 	# Apply the core file with out checking requirements. ${TMPROOT} is
 	# needed by check_requirements but is setup by this file, so it must be
@@ -246,7 +246,7 @@ else
 	TMP_FILE="${TMPROOT}/tmp_volatile.$$"
 	rm -f "$TMP_FILE"
 
-	CFGFILES="`ls -1 "${CFGDIR}" | grep -v "^${COREDEF}\$" | sort`"
+	CFGFILES="$(ls -1 "${CFGDIR}" | grep -v "^${COREDEF}\$" | sort)"
 	for file in ${CFGFILES}; do
 		cat "${CFGDIR}/${file}" >> "$TMP_FILE"
 	done
@@ -264,7 +264,7 @@ else
 	fi
 	rm "$TMP_FILE"
 
-	[ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache
+	[ -e "${ROOT_DIR}/etc/volatile.cache.build" ] && sync && mv "${ROOT_DIR}/etc/volatile.cache.build" "${ROOT_DIR}/etc/volatile.cache"
 fi
 
 if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ]
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] initscripts: Fix populate-volatile.sh bug when file/dir exists
  2020-07-24 17:12 [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh Andrei Gherzan
@ 2020-07-24 17:12 ` Andrei Gherzan
  2020-07-25  5:14 ` [OE-core] [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh Khem Raj
  1 sibling, 0 replies; 5+ messages in thread
From: Andrei Gherzan @ 2020-07-24 17:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Andrei Gherzan

The blocks which test for entry exitence (file or directory) use a
`A && B || C` syntax. This form is not behaving as a if-then-else block
even the code logic assumes that. C may run when A is true which breaks
the case where VERBOSE is 'no' but the file/directory exists.

Along with fixing these specific issues, this patch fixes the other
instances where blocks of form `A && B || C` are used as if-then-else.

Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
---
 .../initscripts-1.0/populate-volatile.sh      | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index 3a265329f0..f21f48dd30 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -26,15 +26,15 @@ COREDEF="00_core"
 
 create_file() {
 	EXEC=""
-	[ -z "$2" ] && {
+	if [ -z "$2" ]; then
 		EXEC="
 		touch \"$1\";
 		"
-	} || {
+	else
 		EXEC="
 		cp \"$2\" \"$1\";
 		"
-	}
+	fi
 	EXEC="
 	${EXEC}
 	chown ${TUSER}:${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1;
@@ -42,9 +42,9 @@ create_file() {
 
 	test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
 
-	[ -e "$1" ] && {
+	if [ -e "$1" ]; then
 		[ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
-	} || {
+	else
 		if [ -z "$ROOT_DIR" ]; then
 			eval "$EXEC"
 		else
@@ -54,7 +54,7 @@ create_file() {
 			# run on target to set up the correct files and directories.
 			eval "$EXEC" > /dev/null 2>&1
 		fi
-	}
+	fi
 }
 
 mk_dir() {
@@ -64,9 +64,9 @@ mk_dir() {
 	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
 
 	test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
-	[ -e "$1" ] && {
+	if [ -e "$1" ]; then
 		[ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
-	} || {
+	else
 		if [ -z "$ROOT_DIR" ]; then
 			eval "$EXEC"
 		else
@@ -74,7 +74,7 @@ mk_dir() {
 			# not be logged.
 			eval "$EXEC" > /dev/null 2>&1
 		fi
-	}
+	fi
 }
 
 link_file() {
@@ -188,13 +188,13 @@ apply_cfgfile() {
 		[ -L "${TNAME}" ] && {
 			[ "${VERBOSE}" != "no" ] && echo "Found link."
 			NEWNAME=$(ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/')
-			echo "${NEWNAME}" | grep -v "^/" >/dev/null && {
+			if echo "${NEWNAME}" | grep -v "^/" >/dev/null; then
 				TNAME="$(echo "${TNAME}" | sed -e 's@\(.*\)/.*@\1@')/${NEWNAME}"
 				[ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-."
-			} || {
+			else
 				TNAME="${NEWNAME}"
 				[ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-."
-			}
+			fi
 		}
 
 		case "${TTYPE}" in
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh
  2020-07-24 17:12 [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh Andrei Gherzan
  2020-07-24 17:12 ` [PATCH 2/2] initscripts: Fix populate-volatile.sh bug when file/dir exists Andrei Gherzan
@ 2020-07-25  5:14 ` Khem Raj
  2020-07-25 12:08   ` Andrei Gherzan
  1 sibling, 1 reply; 5+ messages in thread
From: Khem Raj @ 2020-07-25  5:14 UTC (permalink / raw)
  To: Andrei Gherzan; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 8469 bytes --]

What all shells has it been tested for ?

On Fri, Jul 24, 2020 at 10:12 AM Andrei Gherzan <andrei@gherzan.ro> wrote:

> Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
> ---
>  .../initscripts-1.0/populate-volatile.sh      | 58 +++++++++----------
>  1 file changed, 29 insertions(+), 29 deletions(-)
>
> diff --git
> a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
> b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
> index 1c525b71bd..3a265329f0 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
> @@ -9,10 +9,10 @@
>  ### END INIT INFO
>
>  # Get ROOT_DIR
> -DIRNAME=`dirname $0`
> -ROOT_DIR=`echo $DIRNAME | sed -ne 's:/etc/.*::p'`
> +DIRNAME="$(dirname "$0")"
> +ROOT_DIR="$(echo "$DIRNAME" | sed -ne 's:/etc/.*::p')"
>
> -[ -e ${ROOT_DIR}/etc/default/rcS ] && . ${ROOT_DIR}/etc/default/rcS
> +[ -e "${ROOT_DIR}/etc/default/rcS" ] && . "${ROOT_DIR}/etc/default/rcS"
>  # When running populate-volatile.sh at rootfs time, disable cache.
>  [ -n "$ROOT_DIR" ] && VOLATILE_ENABLE_CACHE=no
>  # If rootfs is read-only, disable cache.
> @@ -46,13 +46,13 @@ create_file() {
>                 [ "${VERBOSE}" != "no" ] && echo "Target already exists.
> Skipping."
>         } || {
>                 if [ -z "$ROOT_DIR" ]; then
> -                       eval $EXEC
> +                       eval "$EXEC"
>                 else
>                         # Creating some files at rootfs time may fail and
> should fail,
>                         # but these failures should not be logged to make
> sure the do_rootfs
>                         # process doesn't fail. This does no harm, as this
> script will
>                         # run on target to set up the correct files and
> directories.
> -                       eval $EXEC > /dev/null 2>&1
> +                       eval "$EXEC" > /dev/null 2>&1
>                 fi
>         }
>  }
> @@ -68,11 +68,11 @@ mk_dir() {
>                 [ "${VERBOSE}" != "no" ] && echo "Target already exists.
> Skipping."
>         } || {
>                 if [ -z "$ROOT_DIR" ]; then
> -                       eval $EXEC
> +                       eval "$EXEC"
>                 else
>                         # For the same reason with create_file(), failures
> should
>                         # not be logged.
> -                       eval $EXEC > /dev/null 2>&1
> +                       eval "$EXEC" > /dev/null 2>&1
>                 fi
>         }
>  }
> @@ -96,11 +96,11 @@ link_file() {
>         test "$VOLATILE_ENABLE_CACHE" = yes && echo "   $EXEC" >>
> /etc/volatile.cache.build
>
>         if [ -z "$ROOT_DIR" ]; then
> -               eval $EXEC
> +               eval "$EXEC"
>         else
>                 # For the same reason with create_file(), failures should
>                 # not be logged.
> -               eval $EXEC > /dev/null 2>&1
> +               eval "$EXEC" > /dev/null 2>&1
>         fi
>  }
>
> @@ -117,11 +117,11 @@ check_requirements() {
>         TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
>         TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
>
> -       sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/passwd | sort | uniq >
> "${TMP_DEFINED}"
> -       cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 2 >
> "${TMP_INTERMED}"
> +       sed 's@\(^:\)*:.*@\1@' "${ROOT_DIR}/etc/passwd" | sort | uniq >
> "${TMP_DEFINED}"
> +       grep -v "^#" "${CFGFILE}" | cut -s -d " " -f 2 > "${TMP_INTERMED}"
>         cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq >
> "${TMP_COMBINED}"
> -       NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
> -       NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
> +       NR_DEFINED_USERS="$(wc -l < "${TMP_DEFINED}")"
> +       NR_COMBINED_USERS="$(wc -l < "${TMP_COMBINED}")"
>
>         [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
>                 echo "Undefined users:"
> @@ -131,12 +131,12 @@ check_requirements() {
>         }
>
>
> -       sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/group | sort | uniq >
> "${TMP_DEFINED}"
> -       cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 3 >
> "${TMP_INTERMED}"
> +       sed 's@\(^:\)*:.*@\1@' "${ROOT_DIR}/etc/group" | sort | uniq >
> "${TMP_DEFINED}"
> +       grep -v "^#" "${CFGFILE}" | cut -s -d " " -f 3 > "${TMP_INTERMED}"
>         cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq >
> "${TMP_COMBINED}"
>
> -       NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
> -       NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
> +       NR_DEFINED_GROUPS="$(wc -l < "${TMP_DEFINED}")"
> +       NR_COMBINED_GROUPS="$(wc -l < "${TMP_COMBINED}")"
>
>         [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
>                 echo "Undefined groups:"
> @@ -157,13 +157,13 @@ apply_cfgfile() {
>
>         [ "${VERBOSE}" != "no" ] && echo "Applying ${CFGFILE}"
>
> -       [ "${SKIP_REQUIREMENTS}" == "yes" ] || check_requirements
> "${CFGFILE}" || {
> +       [ "${SKIP_REQUIREMENTS}" = "yes" ] || check_requirements
> "${CFGFILE}" || {
>                 echo "Skipping ${CFGFILE}"
>                 return 1
>         }
>
> -       cat ${CFGFILE} | sed 's/#.*//' | \
> -       while read TTYPE TUSER TGROUP TMODE TNAME TLTARGET; do
> +       sed 's/#.*//' "${CFGFILE}" | \
> +       while read -r TTYPE TUSER TGROUP TMODE TNAME TLTARGET; do
>                 test -z "${TLTARGET}" && continue
>                 TNAME=${ROOT_DIR}${TNAME}
>                 [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
> @@ -187,9 +187,9 @@ apply_cfgfile() {
>
>                 [ -L "${TNAME}" ] && {
>                         [ "${VERBOSE}" != "no" ] && echo "Found link."
> -                       NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*->
> \(.*\)$/\1/'`
> -                       echo ${NEWNAME} | grep -v "^/" >/dev/null && {
> -                               TNAME="`echo ${TNAME} | sed -e 's@
> \(.*\)/.*@\1@'`/${NEWNAME}"
> +                       NEWNAME=$(ls -l "${TNAME}" | sed -e 's/^.*->
> \(.*\)$/\1/')
> +                       echo "${NEWNAME}" | grep -v "^/" >/dev/null && {
> +                               TNAME="$(echo "${TNAME}" | sed -e 's@
> \(.*\)/.*@\1@')/${NEWNAME}"
>                                 [ "${VERBOSE}" != "no" ] && echo
> "Converted relative linktarget to absolute path -${TNAME}-."
>                         } || {
>                                 TNAME="${NEWNAME}"
> @@ -217,7 +217,7 @@ apply_cfgfile() {
>
>  clearcache=0
>  exec 9</proc/cmdline
> -while read line <&9
> +while read -r line <&9
>  do
>         case "$line" in
>                 *clearcache*)  clearcache=1
> @@ -228,11 +228,11 @@ do
>  done
>  exec 9>&-
>
> -if test -e ${ROOT_DIR}/etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" =
> "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
> +if test -e "${ROOT_DIR}/etc/volatile.cache" -a "$VOLATILE_ENABLE_CACHE" =
> "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
>  then
> -       sh ${ROOT_DIR}/etc/volatile.cache
> +       sh "${ROOT_DIR}/etc/volatile.cache"
>  else
> -       rm -f ${ROOT_DIR}/etc/volatile.cache
> ${ROOT_DIR}/etc/volatile.cache.build
> +       rm -f "${ROOT_DIR}/etc/volatile.cache"
> "${ROOT_DIR}/etc/volatile.cache.build"
>
>         # Apply the core file with out checking requirements. ${TMPROOT} is
>         # needed by check_requirements but is setup by this file, so it
> must be
> @@ -246,7 +246,7 @@ else
>         TMP_FILE="${TMPROOT}/tmp_volatile.$$"
>         rm -f "$TMP_FILE"
>
> -       CFGFILES="`ls -1 "${CFGDIR}" | grep -v "^${COREDEF}\$" | sort`"
> +       CFGFILES="$(ls -1 "${CFGDIR}" | grep -v "^${COREDEF}\$" | sort)"
>         for file in ${CFGFILES}; do
>                 cat "${CFGDIR}/${file}" >> "$TMP_FILE"
>         done
> @@ -264,7 +264,7 @@ else
>         fi
>         rm "$TMP_FILE"
>
> -       [ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv
> ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache
> +       [ -e "${ROOT_DIR}/etc/volatile.cache.build" ] && sync && mv
> "${ROOT_DIR}/etc/volatile.cache.build" "${ROOT_DIR}/etc/volatile.cache"
>  fi
>
>  if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f
> /var/run/ld.so.cache ]
> --
> 2.17.1
>
> 
>

[-- Attachment #2: Type: text/html, Size: 11680 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh
  2020-07-25  5:14 ` [OE-core] [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh Khem Raj
@ 2020-07-25 12:08   ` Andrei Gherzan
  2020-07-26 14:02     ` Khem Raj
  0 siblings, 1 reply; 5+ messages in thread
From: Andrei Gherzan @ 2020-07-25 12:08 UTC (permalink / raw)
  To: Khem Raj; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

On Sat, Jul 25, 2020 at 6:14 AM Khem Raj <raj.khem@gmail.com> wrote:

> What all shells has it been tested for ?
>

I've used shellcheck for static analysis and tested at runtime with busybox
shell.

Andrei

[-- Attachment #2: Type: text/html, Size: 592 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh
  2020-07-25 12:08   ` Andrei Gherzan
@ 2020-07-26 14:02     ` Khem Raj
  0 siblings, 0 replies; 5+ messages in thread
From: Khem Raj @ 2020-07-26 14:02 UTC (permalink / raw)
  To: Andrei Gherzan; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

On Sat, Jul 25, 2020 at 5:08 AM Andrei Gherzan <andrei@gherzan.ro> wrote:

>
> On Sat, Jul 25, 2020 at 6:14 AM Khem Raj <raj.khem@gmail.com> wrote:
>
>> What all shells has it been tested for ?
>>
>
> I've used shellcheck for static analysis and tested at runtime with
> busybox shell.
>

Thanks if it works with busybox ash I am happy with the patch

>
> Andrei
>

[-- Attachment #2: Type: text/html, Size: 1289 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-26 14:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 17:12 [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh Andrei Gherzan
2020-07-24 17:12 ` [PATCH 2/2] initscripts: Fix populate-volatile.sh bug when file/dir exists Andrei Gherzan
2020-07-25  5:14 ` [OE-core] [PATCH 1/2] initscripts: Fix various shellcheck warnings in populate-volatile.sh Khem Raj
2020-07-25 12:08   ` Andrei Gherzan
2020-07-26 14:02     ` Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.