From 84c8616cb9b8f3847f6a8581e49e92d02b335beb Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 8 Sep 2010 09:35:30 -0700 Subject: Fix quoting issues with conversion to lower case Add common shell function to convert to lower case. Part of Bug 6132 --- scripts/install-system | 10 +++++++--- scripts/install/install-functions | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/install-system b/scripts/install-system index 64e2915f..4281fc8d 100755 --- a/scripts/install-system +++ b/scripts/install-system @@ -101,18 +101,22 @@ turnoffswap () { fi } +tolower () { + echo "$*" | tr '[:upper:]' '[:lower:]' +} + # Validates a user response. Returns the response if valid. # Returns the default is the user just hits enter. # Returns nothing if not valid. Default parameter is $1. # Options are in $2. If options are defined return must be a member # of the enum. get_response () { - ldefault=$(echo "$1" | tr [:upper:] [:lower:]) - loptions=$(echo "$2" | tr [:upper:] [:lower:]) + local ldefault=$(tolower "$1") + local loptions=$(tolower "$2") # get the response from the user read myresponse - myresponse=$(echo "$myresponse" | tr [:upper:] [:lower:]) + myresponse=$(tolower "$myresponse") # Check to see if the user accepts the default if [ -z "$myresponse" ]; then diff --git a/scripts/install/install-functions b/scripts/install/install-functions index ff4d6f48..ffaea22d 100755 --- a/scripts/install/install-functions +++ b/scripts/install/install-functions @@ -83,18 +83,22 @@ becho () echo -e "$*" } +tolower () { + echo "$*" | tr '[:upper:]' '[:lower:]' +} + # Validates a user response. Returns the response if valid. # Returns the default is the user just hits enter. # Returns nothing if not valid. Default parameter is $1. # Options are in $2. If options are defined return must be a member # of the enum. get_response () { - ldefault=$(echo "$1" | tr [:upper:] [:lower:]) - loptions=$(echo "$2" | tr [:upper:] [:lower:]) + local ldefault=$(tolower "$1") + local loptions=$(tolower "$2") # get the response from the user read myresponse - myresponse=$(echo "$myresponse" | tr [:upper:] [:lower:]) + myresponse=$(tolower "$myresponse") # Check to see if the user accepts the default if [ -z "$myresponse" ]; then -- cgit v1.2.3