From 8f463670ed885a3a70e1ac87809b8eda2926fc4d Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Wed, 23 Dec 2020 02:52:26 +0200 Subject: Replace AWK with Bash scripts (#46313) * Replace AWK with Bash scripts * Replace awk usage with Bash or POSIX tr * Simplify genmoduleindex.sh --- eng/build.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'eng/build.sh') diff --git a/eng/build.sh b/eng/build.sh index e3d495687c9..10553485e3a 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -162,7 +162,7 @@ actInt=($(comm -12 <(printf '%s\n' "${actions[@]/#/-}" | sort) <(printf '%s\n' " firstArgumentChecked=0 while [[ $# > 0 ]]; do - opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')" + opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")" if [[ $firstArgumentChecked -eq 0 && $opt =~ ^[a-zA-Z.+]+$ ]]; then if [ $opt == "help" ]; then @@ -188,7 +188,7 @@ while [[ $# > 0 ]]; do showSubsetHelp exit 0 else - passedSubset="$(echo "$2" | awk '{print tolower($0)}')" + passedSubset="$(echo "$2" | tr "[:upper:]" "[:lower:]")" if [ $passedSubset == "help" ]; then showSubsetHelp exit 0 @@ -203,7 +203,7 @@ while [[ $# > 0 ]]; do echo "No architecture supplied. See help (--help) for supported architectures." 1>&2 exit 1 fi - passedArch="$(echo "$2" | awk '{print tolower($0)}')" + passedArch="$(echo "$2" | tr "[:upper:]" "[:lower:]")" case "$passedArch" in x64|x86|arm|armel|arm64|wasm) arch=$passedArch @@ -222,7 +222,7 @@ while [[ $# > 0 ]]; do echo "No configuration supplied. See help (--help) for supported configurations." 1>&2 exit 1 fi - passedConfig="$(echo "$2" | awk '{print tolower($0)}')" + passedConfig="$(echo "$2" | tr "[:upper:]" "[:lower:]")" case "$passedConfig" in debug|release|checked) val="$(tr '[:lower:]' '[:upper:]' <<< ${passedConfig:0:1})${passedConfig:1}" @@ -242,7 +242,7 @@ while [[ $# > 0 ]]; do echo "No framework supplied. See help (--help) for supported frameworks." 1>&2 exit 1 fi - val="$(echo "$2" | awk '{print tolower($0)}')" + val="$(echo "$2" | tr "[:upper:]" "[:lower:]")" arguments="$arguments /p:BuildTargetFramework=$val" shift 2 ;; @@ -252,7 +252,7 @@ while [[ $# > 0 ]]; do echo "No target operating system supplied. See help (--help) for supported target operating systems." 1>&2 exit 1 fi - passedOS="$(echo "$2" | awk '{print tolower($0)}')" + passedOS="$(echo "$2" | tr "[:upper:]" "[:lower:]")" case "$passedOS" in windows) os="windows" ;; @@ -313,7 +313,7 @@ while [[ $# > 0 ]]; do echo "No runtime configuration supplied. See help (--help) for supported runtime configurations." 1>&2 exit 1 fi - passedRuntimeConf="$(echo "$2" | awk '{print tolower($0)}')" + passedRuntimeConf="$(echo "$2" | tr "[:upper:]" "[:lower:]")" case "$passedRuntimeConf" in debug|release|checked) val="$(tr '[:lower:]' '[:upper:]' <<< ${passedRuntimeConf:0:1})${passedRuntimeConf:1}" @@ -333,7 +333,7 @@ while [[ $# > 0 ]]; do echo "No runtime flavor supplied. See help (--help) for supported runtime flavors." 1>&2 exit 1 fi - passedRuntimeFlav="$(echo "$2" | awk '{print tolower($0)}')" + passedRuntimeFlav="$(echo "$2" | tr "[:upper:]" "[:lower:]")" case "$passedRuntimeFlav" in coreclr|mono) val="$(tr '[:lower:]' '[:upper:]' <<< ${passedRuntimeFlav:0:1})${passedRuntimeFlav:1}" @@ -353,7 +353,7 @@ while [[ $# > 0 ]]; do echo "No libraries configuration supplied. See help (--help) for supported libraries configurations." 1>&2 exit 1 fi - passedLibConf="$(echo "$2" | awk '{print tolower($0)}')" + passedLibConf="$(echo "$2" | tr "[:upper:]" "[:lower:]")" case "$passedLibConf" in debug|release) val="$(tr '[:lower:]' '[:upper:]' <<< ${passedLibConf:0:1})${passedLibConf:1}" @@ -398,7 +398,7 @@ while [[ $# > 0 ]]; do echo "No value for portablebuild is supplied. See help (--help) for supported values." 1>&2 exit 1 fi - passedPortable="$(echo "$2" | awk '{print tolower($0)}')" + passedPortable="$(echo "$2" | tr "[:upper:]" "[:lower:]")" if [ "$passedPortable" = false ]; then portableBuild=0 arguments="$arguments /p:PortableBuild=false" @@ -411,7 +411,7 @@ while [[ $# > 0 ]]; do echo "No value for keepNativeSymbols is supplied. See help (--help) for supported values." 1>&2 exit 1 fi - passedKeepNativeSymbols="$(echo "$2" | awk '{print tolower($0)}')" + passedKeepNativeSymbols="$(echo "$2" | tr "[:upper:]" "[:lower:]")" if [ "$passedKeepNativeSymbols" = true ]; then arguments="$arguments /p:KeepNativeSymbols=true" fi @@ -424,7 +424,7 @@ while [[ $# > 0 ]]; do arguments="$arguments /p:Ninja=true" shift 1 else - ninja="$(echo "$2" | awk '{print tolower($0)}')" + ninja="$(echo "$2" | tr "[:upper:]" "[:lower:]")" if [ "$ninja" = true ]; then arguments="$arguments /p:Ninja=true" shift 2 -- cgit v1.2.3