r4182 - in trunk/bootscripts: . lfs/init.d

nathan at linuxfromscratch.org nathan at linuxfromscratch.org
Tue Sep 21 21:29:20 PDT 2004


Author: nathan
Date: 2004-09-21 22:29:18 -0600 (Tue, 21 Sep 2004)
New Revision: 4182

Modified:
   trunk/bootscripts/CHANGELOG
   trunk/bootscripts/lfs/init.d/functions
Log:
Enhanced boot_mesg to wrap text, as well as append onto old text

Modified: trunk/bootscripts/CHANGELOG
===================================================================
--- trunk/bootscripts/CHANGELOG	2004-09-22 03:17:06 UTC (rev 4181)
+++ trunk/bootscripts/CHANGELOG	2004-09-22 04:29:18 UTC (rev 4182)
@@ -1,3 +1,7 @@
+n/a - September 21, 2004
+	* boot_mesg has been enhanced.  Subsequent calls will overwrite previous text,
+	  and it will wrap text based upon the variable ${WCOL}.
+
 n/a - September 16, 2004
 	* nework interfaces are now brought down in reverse order
 

Modified: trunk/bootscripts/lfs/init.d/functions
===================================================================
--- trunk/bootscripts/lfs/init.d/functions	2004-09-22 03:17:06 UTC (rev 4181)
+++ trunk/bootscripts/lfs/init.d/functions	2004-09-22 04:29:18 UTC (rev 4182)
@@ -33,7 +33,7 @@
 # Set Cursur Position Commands, used via echo -e
 SET_COL="\\033[${COL}G"      # at the $COL char
 SET_WCOL="\\033[${WCOL}G"    # at the $WCOL char
-CURS_UP="\\033[1A \\033[0G"  # Up one line, at the 0'th char
+CURS_UP="\\033[1A\\033[0G"  # Up one line, at the 0'th char
 
 # Set color commands, used via echo -e
 NORMAL="\\033[0;39m"         # Standard console grey
@@ -48,10 +48,30 @@
 
 boot_mesg()
 {
+	local nlBOOTMESG=""
+
+	# First call to boot_mesg, set BOOTMESG normally
 	if [ -z "$BOOTMESG" ]; then
 		BOOTMESG="$@"
-		echo -e "${NORMAL}${BOOTMESG}"
+	# Subsequent calls will overwrite the text already on the screen
+	# with replacement text by counting the lines in the last BOOTMESG
+	# and calling CURS_UP that many times
+	# It will also append our new text onto the BOOTMESG variable
+	else
+		local length=`echo -e "$BOOTMESG" | wc -l`
+		local count=0
+		BOOTMESG="$BOOTMESG $@"
+		while [ "${count}" -lt "${length}" ]; do
+			echo -e -n "$CURS_UP"
+			count=$((${count}+1))
+		done
 	fi
+
+	# This will limit BOOTMESG to be no longer then what WCOL is set to,
+	# by adding \n's where appropriate.
+	BOOTMESG=`echo ${BOOTMESG} | sed -n -e "s/\\\\n/\n/g;L ${WCOL}"`
+
+	echo -e "${NORMAL}${BOOTMESG}"
 }
 
 echo_ok()




More information about the lfs-book mailing list