From dc4cee8f5987098a07a8b272573424b599a52598 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 17 Nov 2007 12:03:59 -0600 Subject: Don't assume sh == bash Signed-off-by: Dan McGee --- functions | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions b/functions index b55e507..4ded39e 100644 --- a/functions +++ b/functions @@ -1,6 +1,5 @@ -#!/bin/bash # -# functions +# initscripts functions # # width: -- cgit v1.2.3 From 980791fd888b6efff6319c77363aab473166ca6b Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 30 Nov 2007 09:17:15 -0600 Subject: Make functions sh compatible There is no reason to use bashisms in functions, so eliminate any and use printf instead of echo options which are not guaranteed to be implemented in a POSIX sh. Signed-off-by: Dan McGee --- functions | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/functions b/functions index 4ded39e..20931b5 100644 --- a/functions +++ b/functions @@ -16,7 +16,7 @@ elif [ ! -t 1 ]; then USECOLOR="" fi # we use 13 characters for our own stuff -STAT_COL=$[$STAT_COL - 13] +STAT_COL=$(($STAT_COL - 13)) # disable colors on broken terminals TERM_COLORS="$(tput colors 2>/dev/null)" @@ -67,44 +67,44 @@ PREFIX_HL=" >" # functions: deltext() { - echo -ne "$DEL_TEXT" + printf "${DEL_TEXT}" } printhl() { - echo -e "$C_OTHER$PREFIX_HL $C_H1$1$C_CLEAR " + printf "${C_OTHER}${PREFIX_HL} ${C_H1}${1}${C_CLEAR} \n" } printsep() { - echo -e "\n$C_SEPARATOR ------------------------------\n" + printf "\n${C_SEPARATOR} ------------------------------\n" } stat_bkgd() { - echo -ne "$C_OTHER$PREFIX_REG $C_MAIN$1$C_CLEAR " + printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} " deltext - echo -ne " $C_OTHER[${C_BKGD}BKGD$C_OTHER]$C_CLEAR " + printf " ${C_OTHER}[${C_BKGD}BKGD${C_OTHER}]${C_CLEAR} " } stat_busy() { - echo -ne "$C_OTHER$PREFIX_REG $C_MAIN$1$C_CLEAR " - echo -ne "${SAVE_POSITION}" + printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} " + printf "${SAVE_POSITION}" deltext - echo -ne " $C_OTHER[${C_BUSY}BUSY$C_OTHER]$C_CLEAR " + printf " ${C_OTHER}[${C_BUSY}BUSY${C_OTHER}]${C_CLEAR} " } stat_append() { - echo -ne "${RESTORE_POSITION}" - echo -ne "$C_MAIN$1$C_CLEAR" - echo -ne "${SAVE_POSITION}" + printf "${RESTORE_POSITION}" + printf "${C_MAIN}${1}${C_CLEAR}" + printf "${SAVE_POSITION}" } stat_done() { deltext - echo -e " $C_OTHER[${C_DONE}DONE$C_OTHER]$C_CLEAR " + printf " ${C_OTHER}[${C_DONE}DONE${C_OTHER}]${C_CLEAR} \n" } stat_fail() { deltext - echo -e " $C_OTHER[${C_FAIL}FAIL$C_OTHER]$C_CLEAR " + printf " ${C_OTHER}[${C_FAIL}FAIL${C_OTHER}]${C_CLEAR} \n" } stat_die() { -- cgit v1.2.3 From e3985084056bb80c886ea649674c3da5b906ccab Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 30 Nov 2007 09:18:26 -0600 Subject: Make install.sh sh compatible Signed-off-by: Dan McGee --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e06b6d0..a082016 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,7 @@ #!/bin/sh -install -d -m755 ${DESTDIR}/etc/{rc.d,conf.d} || exit 1 +install -d -m755 ${DESTDIR}/etc/rc.d || exit 1 +install -d -m755 ${DESTDIR}/etc/conf.d || exit 1 install -d -m755 ${DESTDIR}/etc/rc.d/functions.d/ || exit 1 for i in inittab rc.conf; do -- cgit v1.2.3 From 7b6fddfb12106c9485a9ceb8fa1876a501d1f181 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 30 Nov 2007 09:23:02 -0600 Subject: Remove some bashisms from network, even though we cannot convert it Since netfs and network source rc.conf, we cannot fully convert it to an sh script. However, we can get rid of a few things that are not sh compatible. Signed-off-by: Dan McGee --- netfs | 1 + network | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/netfs b/netfs index c381594..25db4e1 100755 --- a/netfs +++ b/netfs @@ -1,5 +1,6 @@ #!/bin/bash +# sourcing our current rc.conf requires this to be a bash script . /etc/rc.conf . /etc/rc.d/functions diff --git a/network b/network index fbe77d8..81996ef 100755 --- a/network +++ b/network @@ -30,7 +30,8 @@ ifup() eval ifcfg="\$${1}" if [ "$ifcfg" = "dhcp" ]; then # remove the .pid file if it exists - rm -f /var/run/dhcpcd-${1}.{pid,cache} >/dev/null 2>&1 + rm -f /var/run/dhcpcd-${1}.pid >/dev/null 2>&1 + rm -f /var/run/dhcpcd-${1}.cache >/dev/null 2>&1 /sbin/dhcpcd $DHCPCD_ARGS ${1} else /sbin/ifconfig $ifcfg @@ -59,9 +60,9 @@ iflist() { for ifline in ${INTERFACES[@]}; do if [ "$ifline" = "${ifline#!}" ]; then - echo -en " $ifline:\t" + printf " $ifline:\t" else - echo -en "$ifline:\t" + printf "$ifline:\t" fi eval real_ifline=\$${ifline#!} echo $real_ifline @@ -94,9 +95,9 @@ rtlist() { for rtline in ${ROUTES[@]}; do if [ "$rtline" = "${rtline#!}" ]; then - echo -en " $rtline:\t" + printf " $rtline:\t" else - echo -en "$rtline:\t" + printf "$rtline:\t" fi eval real_rtline=\$${rtline#!} echo $real_rtline -- cgit v1.2.3 From fbb8d26a81dc220d7795be871e09c89fd0e03a76 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 30 Nov 2007 09:30:05 -0600 Subject: Remove echo -e usage from rc.sysinit Use the always available (in sh) printf method instead. Signed-off-by: Dan McGee --- rc.sysinit | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 6dc07ae..d825b35 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -194,7 +194,7 @@ if [ -f /etc/crypttab -a -n "$(grep -v ^# /etc/crypttab | grep -v ^$)" ]; then fi fi elif [ "${cpass}" = "ASK" ]; then - echo -e "\nOpening '${cname}' volume:" + printf "\nOpening '${cname}' volume:\n" if $CS isLuks $csrc 2>/dev/null; then $CS $copts luksOpen $csrc $cname < /dev/console @@ -369,10 +369,10 @@ if echo "$LOCALE" | /bin/grep -qi utf ; then stat_busy "Setting Consoles to UTF-8" /usr/bin/kbd_mode -u for i in $(seq 1 63); do - echo -ne "\e%G" > /dev/vc/${i} + printf "\e%G" > /dev/vc/${i} done # the $CONSOLE check helps us avoid this when running scripts from cron - echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then echo -ne "\e%G"; fi' >>/etc/profile.d/locale.sh + echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e%G"; fi' >>/etc/profile.d/locale.sh stat_done status "Loading Keyboard Map: $KEYMAP in utf-8 mode" /bin/loadkeys -q -u $KEYMAP else @@ -396,10 +396,10 @@ if [ -n "$CONSOLEFONT" ]; then stat_fail else for i in $(seq 1 63); do - echo -ne "\e(K" > /dev/vc/${i} + printf "\e(K" > /dev/vc/${i} done # the $CONSOLE check helps us avoid this when running scripts from cron - echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then echo -ne "\e(K"; fi' >>/etc/profile.d/locale.sh + echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e(K"; fi' >>/etc/profile.d/locale.sh stat_done fi fi -- cgit v1.2.3