summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-06-22 23:48:43 -0400
committerMike Frysinger <vapier@gentoo.org>2016-06-22 23:48:43 -0400
commitcc02d07dedbc737855ec0711dd52d4654c9a7404 (patch)
tree3b194f11b878dc4d7ecbb86e8e463f94f63a0e12
parentgenkernel: simplify/robustify --config parsing (diff)
downloadgenkernel-cc02d07dedbc737855ec0711dd52d4654c9a7404.tar.gz
genkernel-cc02d07dedbc737855ec0711dd52d4654c9a7404.tar.bz2
genkernel-cc02d07dedbc737855ec0711dd52d4654c9a7404.zip
clean up extended echo usage
Switch to printf where appropriate, and simplify other locations where the -e option was pointless.
-rwxr-xr-xdefaults/initrd.defaults2
-rw-r--r--defaults/initrd.scripts22
-rwxr-xr-xgen_bootloader.sh4
-rwxr-xr-xgen_compile.sh4
-rwxr-xr-xgen_funcs.sh25
-rwxr-xr-xgen_initramfs.sh4
-rwxr-xr-xgenkernel4
-rw-r--r--netboot/linuxrc.x67
-rwxr-xr-xnetboot/misc/bin/net-setup19
9 files changed, 76 insertions, 75 deletions
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index b63ebd03..940d2df2 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -44,7 +44,7 @@ WHITE=""
# echo "$CLEAR$RESET"
# echo "$CLEAR"
# Just go to the top of the screen
-# echo -n ""
+# printf ""
KV=`uname -r`
KMAJOR=`echo $KV | cut -f1 -d.`
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 703c0fea..4b0bbad2 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -33,7 +33,7 @@ modules_scan() {
MODS=$(cat /etc/modules/${1} 2>/dev/null)
[ -n "${MODS}" ] && [ -z "${QUIET}" ] && \
- echo -ne "${BOLD} ::${NORMAL} Loading from ${1}: "
+ printf "%b" "${BOLD} ::${NORMAL} Loading from ${1}: "
for x in ${MODS}
do
@@ -41,12 +41,12 @@ modules_scan() {
if [ "${MLOAD}" = "${x}" ] # Only module to no-load
then
[ -z "${QUIET}" ] && \
- echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
+ printf "%b\n" "${BOLD} ::${NORMAL} Skipping ${x}..."
elif [ "${MLOAD}" = "${MLIST}" ]
then
if [ -n "${DEBUG}" ]; then
- echo -ne "${BOLD} ::${NORMAL} "
- echo -ne "Scanning for ${x}..."
+ printf "%b" "${BOLD} ::${NORMAL} "
+ printf "%b" "Scanning for ${x}..."
fi
modprobe ${x} > /dev/null 2>&1
loaded=${?}
@@ -58,10 +58,10 @@ modules_scan() {
[ -z "${DEBUG}" -a "${loaded}" = "0" ] && \
[ -z "${QUIET}" ] && \
- echo -en "${x} "
+ printf "%b" "${x} "
else
[ -z "${QUIET}" ] && \
- echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
+ printf "%b\n" "${BOLD} ::${NORMAL} Skipping ${x}..."
fi
done
[ -n "${MODS}" ] && [ -z "${QUIET}" ] && echo
@@ -629,7 +629,7 @@ find_real_device() {
fi
;;
esac
- echo -n "${DEVICE}"
+ printf "%s" "${DEVICE}"
}
check_loop() {
@@ -696,7 +696,7 @@ good_msg() {
msg_string=$1
msg_string="${msg_string:-...}"
- [ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
+ [ "$2" != 1 ] && printf "%b\n" "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
}
bad_msg() {
@@ -705,14 +705,14 @@ bad_msg() {
if [ "$2" != 1 ]
then
splash 'verbose' > /dev/null &
- echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
+ printf "%b\n" "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
fi
}
warn_msg() {
msg_string=$1
msg_string="${msg_string:-...}"
- [ "$2" != 1 ] && echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
+ [ "$2" != 1 ] && printf "%b\n" "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
}
crypt_filter() {
@@ -751,7 +751,7 @@ prompt_user(){
bad_msg "- press Enter for the same"
bad_msg '- type "shell" for a shell'
bad_msg '- type "q" to skip...'
- echo -n "${2}(${oldvalue}) :: "
+ printf "%s" "${2}(${oldvalue}) :: "
read ${1}
case `eval echo '$'${1}` in
'q')
diff --git a/gen_bootloader.sh b/gen_bootloader.sh
index 90c3f9bb..4bbd3036 100755
--- a/gen_bootloader.sh
+++ b/gen_bootloader.sh
@@ -89,12 +89,12 @@ set_bootloader_grub() {
# Add grub configuration to grub.conf
echo "# Genkernel generated entry, see GRUB documentation for details" >> ${GRUB_CONF}
echo "title=Gentoo Linux ($KV)" >> ${GRUB_CONF}
- echo -e "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
+ printf "%b\n" "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
if [ "${BUILD_INITRD}" = '1' ]
then
if [ "${PAT}" -gt '4' ]
then
- echo -e "\tinitrd /initramfs-${KNAME}-${ARCH}-${KV}" >> ${GRUB_CONF}
+ printf "%b\n" "\tinitrd /initramfs-${KNAME}-${ARCH}-${KV}" >> ${GRUB_CONF}
fi
fi
echo >> ${GRUB_CONF}
diff --git a/gen_compile.sh b/gen_compile.sh
index 554e6450..0bb13993 100755
--- a/gen_compile.sh
+++ b/gen_compile.sh
@@ -29,7 +29,7 @@ compile_kernel_args() {
then
ARGS="${ARGS} O=\"${KERNEL_OUTPUTDIR}\""
fi
- echo -n "${ARGS}"
+ printf "%s" "${ARGS}"
}
compile_utils_args()
@@ -61,7 +61,7 @@ compile_utils_args()
ARGS="${ARGS} AS=\"${UTILS_AS}\""
fi
- echo -n "${ARGS}"
+ printf "%s" "${ARGS}"
}
export_utils_args()
diff --git a/gen_funcs.sh b/gen_funcs.sh
index eb807ad9..7e974de1 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -115,11 +115,9 @@ print_info() {
STR="${2}"
fi
- if [ "${NEWLINE}" = '0' ]
- then
- echo -ne "${STR}"
- else
- echo "${STR}"
+ printf "%b" "${STR}"
+ if [ "${NEWLINE}" != '0' ]; then
+ echo
fi
fi
@@ -138,18 +136,17 @@ print_info() {
STR="${STRR}"
fi
- if [ "${NEWLINE}" = '0' ]
- then
- if [ "${TODEBUGCACHE}" = '1' ]; then
- DEBUGCACHE="${DEBUGCACHE}${STR}"
- else
- echo -ne "${STR}" >> ${LOGFILE}
- fi
+ if [ "${TODEBUGCACHE}" = '1' ]; then
+ DEBUGCACHE="${DEBUGCACHE}${STR}"
else
+ printf "%b" "${STR}" >> ${LOGFILE}
+ fi
+
+ if [ "${NEWLINE}" != '0' ]; then
if [ "${TODEBUGCACHE}" = '1' ]; then
- DEBUGCACHE="${DEBUGCACHE}${STR}"$'\n'
+ DEBUGCACHE="${DEBUGCACHE}"$'\n'
else
- echo "${STR}" >> ${LOGFILE}
+ echo >> ${LOGFILE}
fi
fi
fi
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index fdf2eb13..f1133733 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -782,10 +782,10 @@ append_auxilary() {
sed -i "s:^REAL_ROOT=.*$:REAL_ROOT='${REAL_ROOT}':" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
fi
- echo -n 'HWOPTS="$HWOPTS ' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
+ printf "%s" 'HWOPTS="$HWOPTS ' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
for group_modules in ${!MODULES_*}; do
group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
- echo -n "${group} " >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
+ printf "%s" "${group} " >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
done
echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
diff --git a/genkernel b/genkernel
index 506a2ca2..0aad2bf6 100755
--- a/genkernel
+++ b/genkernel
@@ -192,7 +192,7 @@ fi
# print_warning 1 "${BOLD}WARNING${NORMAL}: Another Genkernel instance is running under"
# print_warning 1 " process ID${EX} " 0
# GENPIDS=`ps -C genkernel --no-headers -o pid`
-# echo -n "${GENPIDS}" | sed -e "s/$$//; s/ /, /g"
+# printf "%s" "${GENPIDS}" | sed -e "s/$$//; s/ /, /g"
# echo 'halting...'
# echo
# print_warning 1 'Running multiple genkernels on the same source tree will cause data loss!'
@@ -270,7 +270,7 @@ then
trap "CALLBACK_ESCAPE=1" TERM KILL INT QUIT ABRT
while [[ "${CALLBACK_ESCAPE}" = '0' && ${CALLBACK_COUNT} -lt 5 ]]
do
- sleep 1; echo -n '.';
+ sleep 1; printf '.';
let CALLBACK_COUNT=${CALLBACK_COUNT}+1
done
diff --git a/netboot/linuxrc.x b/netboot/linuxrc.x
index 31b19d0c..4bd711c3 100644
--- a/netboot/linuxrc.x
+++ b/netboot/linuxrc.x
@@ -100,14 +100,14 @@ StartUp() {
if [ -n "`which dropbear 2>/dev/null`" ]
then
# Setup dropbear (sshd)
- echo -e ""
+ echo
mkdir /etc/dropbear
- echo -e ">>> Generating RSA hostkey ..."
+ echo ">>> Generating RSA hostkey ..."
dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
- echo -e ""
- echo -e ">>> Generating DSS hostkey ..."
+ echo
+ echo ">>> Generating DSS hostkey ..."
dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
- echo -e ""
+ echo
dropbear
fi
@@ -126,8 +126,7 @@ StartUp() {
#// show an informative message (with a newline)
einfo() {
- echo -e " * ${*}"
- return 0
+ printf " * %b\n" "$*"
}
#//--------------------------------------------------------------------------------
@@ -266,35 +265,41 @@ SubGenius() {
#//--------------------------------------------------------------------------------
GenMotd() {
- echo -e "" > /etc/motd
- echo -e "" >> /etc/motd
- echo -e "Gentoo Linux; http://www.gentoo.org/" >> /etc/motd
- echo -e " Copyright 2001-${CPYYEAR} Gentoo Foundation; Distributed under the GPL" >> /etc/motd
- echo -e "" >> /etc/motd
- echo -e " Gentoo/${MYARCH} Netboot for ${MACHTYPE} Systems" >> /etc/motd
- echo -e " ${BUILDDATE}" >> /etc/motd
- echo -e "" >> /etc/motd
+ cat <<-EOF >/etc/motd
+
+
+ Gentoo Linux; http://www.gentoo.org/
+ Copyright 2001-${CPYYEAR} Gentoo Foundation; Distributed under the GPL
+
+ Gentoo/${MYARCH} Netboot for ${MACHTYPE} Systems
+ ${BUILDDATE}
+
+EOF
#// If this is the initial startup, then display some messages, otherwise just execute a shell for the user
if [ ! -f "/tmp/.startup" ]; then
if [ -z "${MYIP}" ]; then
- einfo "To configure networking (eth0), do the following:" > /etc/motd2
- echo -e "" >> /etc/motd2
- einfo "For Static IP:" >> /etc/motd2
- einfo "/bin/net-setup <IP Address> <Gateway Address>" >> /etc/motd2
- echo -e "" >> /etc/motd2
- einfo "For Dynamic IP:" >> /etc/motd2
- einfo "/bin/net-setup dhcp" >> /etc/motd2
- echo -e "" >> /etc/motd2
+ (
+ einfo "To configure networking (eth0), do the following:"
+ echo
+ einfo "For Static IP:"
+ einfo "/bin/net-setup <IP Address> <Gateway Address>"
+ echo
+ einfo "For Dynamic IP:"
+ einfo "/bin/net-setup dhcp"
+ echo
+ ) > /etc/motd2
else
- echo -e "" > /etc/motd2
- einfo "Network interface eth0 has been started:" >> /etc/motd2
- einfo " IP Address: ${MYIP}" >> /etc/motd2
- einfo " Gateway: ${MYGW}" >> /etc/motd2
- echo -e "" >> /etc/motd2
- einfo "An sshd server is available on port 22. Please set a root" >> /etc/motd2
- einfo "password via \"passwd\" before using." >> /etc/motd2
- echo -e "" >> /etc/motd2
+ (
+ echo
+ einfo "Network interface eth0 has been started:"
+ einfo " IP Address: ${MYIP}"
+ einfo " Gateway: ${MYGW}"
+ echo
+ einfo "An sshd server is available on port 22. Please set a root"
+ einfo "password via \"passwd\" before using."
+ echo
+ ) > /etc/motd2
fi
fi
}
diff --git a/netboot/misc/bin/net-setup b/netboot/misc/bin/net-setup
index 91c408a3..134065d1 100755
--- a/netboot/misc/bin/net-setup
+++ b/netboot/misc/bin/net-setup
@@ -10,8 +10,7 @@ MYGW=""
# void einfo(char* message)
# show an informative message (with a newline)
einfo() {
- echo -e " * ${*}"
- return 0
+ printf " * %b\n" "$*"
}
#//--------------------------------------------------------------------------------
@@ -30,9 +29,9 @@ SetupNetwork() {
#// Check second param
if [ -z "${2}" ]; then
- echo -e ""
+ echo
einfo "Please specify a gateway address."
- echo -e ""
+ echo
exit
fi
@@ -63,11 +62,11 @@ SetupNetwork() {
#// Check first param
if [ -z "${1}" ]; then
- echo -e ""
+ echo
einfo "Please specify \"dhcp\" for setting up networking via dhcp or"
einfo "specify an IP Address and gateway address to configure static"
einfo "networking."
- echo -e ""
+ echo
exit 0
fi
@@ -78,15 +77,15 @@ SetupNetwork ${1} ${2} ${3}
#// Was the network setup?
if [ ! -z "$(ifconfig | grep "eth0")" ]; then
- echo -e ""
+ echo
einfo "Network interface eth0 has been started:"
einfo " IP Address: ${MYIP}"
einfo " Gateway: ${MYGW}"
- echo -e ""
+ echo
einfo "An sshd server is available on port 22. Please set a root"
einfo "password via \"passwd\" before using."
- echo -e ""
- echo -e ""
+ echo
+ echo
fi
#//--------------------------------------------------------------------------------