Changeset 7928

Show
Ignore:
Timestamp:
02/22/07 15:29:24 (1 year ago)
Author:
dnicholson
Message:

Feature test for `echo -[en]' for POSIX compatibility

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bootscripts/ChangeLog

    r7911 r7928  
     12007-02-22      Dan Nicholson   <dnicholson@linuxfromscratch.org> 
     2        * lfs/init.d/functions: In order to provide an `echo' which provides 
     3          handles the -e and -n options for all POSIX shells, a feature test 
     4          is added which stores its result in $ECHO. /bin/echo will be used 
     5          if the default echo is not capable. Changed the existing functions 
     6          to reference $ECHO when needed. 
     7        * lfs/init.d/console: Use $ECHO when -en is needed. 
     8 
    192007-02-03      Bryan Kadzban   <bryan@linuxfromscratch.org> 
    210        * ChangeLog: Rename from CHANGELOG, start using GNU style entries. 
  • trunk/bootscripts/lfs/init.d/console

    r7655 r7928  
    4343                # desired mode 
    4444                is_true "${UNICODE}" && 
    45                         MODE_COMMAND="echo -en '\033%G' && kbd_mode -u" || 
    46                         MODE_COMMAND="echo -en '\033%@\033(K' && kbd_mode -a" 
     45                        MODE_COMMAND="${ECHO} -en '\033%G' && kbd_mode -u" || 
     46                        MODE_COMMAND="${ECHO} -en '\033%@\033(K' && kbd_mode -a" 
    4747                 
    4848                # On framebuffer consoles, font has to be set for each vt in 
  • trunk/bootscripts/lfs/init.d/functions

    r7446 r7928  
    4141WCOL=$((${COL} - 2)) 
    4242 
    43 ## Set Cursor Position Commands, used via echo -e 
     43## Provide an echo that supports -e and -n 
     44# If formatting is needed, $ECHO should be used 
     45case "`echo -e -n test`" in 
     46        -[en]*) 
     47                ECHO=/bin/echo 
     48                ;; 
     49        *) 
     50                ECHO=echo 
     51                ;; 
     52esac 
     53 
     54## Set Cursor Position Commands, used via $ECHO 
    4455SET_COL="\\033[${COL}G"      # at the $COL char 
    4556SET_WCOL="\\033[${WCOL}G"    # at the $WCOL char 
    4657CURS_UP="\\033[1A\\033[0G"   # Up one line, at the 0'th char 
    4758 
    48 ## Set color commands, used via echo -e 
     59## Set color commands, used via $ECHO 
    4960# Please consult `man console_codes for more information 
    5061# under the "ECMA-48 Set Graphics Rendition" section 
     
    105116 
    106117        # Print the message to the screen 
    107         echo ${ECHOPARM} -e "${2}${1}" 
     118        ${ECHO} ${ECHOPARM} -e "${2}${1}" 
    108119         
    109120} 
     
    118129{ 
    119130        # Left in for backwards compatibility 
    120         echo -n "" 
     131        : 
    121132} 
    122133 
    123134echo_ok() 
    124135{ 
    125         echo -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]" 
    126         echo -e "${NORMAL}" 
     136        ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]" 
     137        ${ECHO} -e "${NORMAL}" 
    127138        boot_mesg_flush 
    128139} 
     
    130141echo_failure() 
    131142{ 
    132         echo -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]" 
    133         echo -e "${NORMAL}" 
     143        ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]" 
     144        ${ECHO} -e "${NORMAL}" 
    134145        boot_mesg_flush 
    135146} 
     
    137148echo_warning() 
    138149{ 
    139         echo -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]" 
    140         echo -e "${NORMAL}" 
     150        ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]" 
     151        ${ECHO} -e "${NORMAL}" 
    141152        boot_mesg_flush 
    142153} 
     
    210221                        case "${2}" in 
    211222                                running) 
    212                                         echo -e -n "${CURS_UP}" 
    213                                         echo -e -n "\\033[${STRING_LENGTH}G   " 
     223                                        ${ECHO} -e -n "${CURS_UP}" 
     224                                        ${ECHO} -e -n "\\033[${STRING_LENGTH}G   " 
    214225                                        boot_mesg "Already running." ${WARNING} 
    215226                                        echo_warning 
    216227                                        ;; 
    217228                                not_running) 
    218                                         echo -e -n "${CURS_UP}" 
    219                                         echo -e -n "\\033[${STRING_LENGTH}G   " 
     229                                        ${ECHO} -e -n "${CURS_UP}" 
     230                                        ${ECHO} -e -n "\\033[${STRING_LENGTH}G   " 
    220231                                        boot_mesg "Not running." ${WARNING} 
    221232                                        echo_warning 
    222233                                        ;; 
    223234                                not_available) 
    224                                         echo -e -n "${CURS_UP}" 
    225                                         echo -e -n "\\033[${STRING_LENGTH}G   " 
     235                                        ${ECHO} -e -n "${CURS_UP}" 
     236                                        ${ECHO} -e -n "\\033[${STRING_LENGTH}G   " 
    226237                                        boot_mesg "Not available." ${WARNING} 
    227238                                        echo_warning 
     
    279290 
    280291        if [ -n "${pidlist}" ]; then 
    281                 echo -e "${INFO}${base} is running with Process"\ 
     292                ${ECHO} -e "${INFO}${base} is running with Process"\ 
    282293                        "ID(s) ${pidlist}.${NORMAL}" 
    283294        else 
    284295                if [ -n "${base}" -a -e "/var/run/${base}.pid" ]; then 
    285                         echo -e "${WARNING}${1} is not running but"\ 
     296                        ${ECHO} -e "${WARNING}${1} is not running but"\ 
    286297                                "/var/run/${base}.pid exists.${NORMAL}" 
    287298                else 
    288299                        if [ -n "${PIDFILE}" -a -e "${PIDFILE}" ]; then 
    289                                 echo -e "${WARNING}${1} is not running"\ 
     300                                ${ECHO} -e "${WARNING}${1} is not running"\ 
    290301                                        "but ${PIDFILE} exists.${NORMAL}" 
    291302                        else 
    292                                 echo -e "${INFO}${1} is not running.${NORMAL}" 
     303                                ${ECHO} -e "${INFO}${1} is not running.${NORMAL}" 
    293304                        fi 
    294305                fi 
     
    635646log_success_msg() 
    636647{ 
    637         echo -n -e "${BOOTMESG_PREFIX}${@}" 
    638         echo -e "${SET_COL}""${BRACKET}""[""${SUCCESS}""  OK  ""${BRACKET}""]""${NORMAL}" 
     648        ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" 
     649        ${ECHO} -e "${SET_COL}""${BRACKET}""[""${SUCCESS}""  OK  ""${BRACKET}""]""${NORMAL}" 
    639650        return 0 
    640651} 
     
    655666#******************************************************************************* 
    656667log_failure_msg() { 
    657         echo -n -e "${BOOTMESG_PREFIX}${@}" 
    658         echo -e "${SET_COL}""${BRACKET}""[""${FAILURE}"" FAIL ""${BRACKET}""]""${NORMAL}" 
     668        ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" 
     669        ${ECHO} -e "${SET_COL}""${BRACKET}""[""${FAILURE}"" FAIL ""${BRACKET}""]""${NORMAL}" 
    659670        return 0 
    660671} 
     
    675686#******************************************************************************* 
    676687log_warning_msg() { 
    677         echo -n -e "${BOOTMESG_PREFIX}${@}" 
    678         echo -e "${SET_COL}""${BRACKET}""[""${WARNING}"" WARN ""${BRACKET}""]""${NORMAL}" 
     688        ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" 
     689        ${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" WARN ""${BRACKET}""]""${NORMAL}" 
    679690        return 0 
    680691}