From: Kevin Day Date: Sat, 28 Jun 2025 03:38:35 +0000 (-0500) Subject: Cleanup: Apply new script practices. X-Git-Tag: 0.6.14~3 X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=f6868168d36a5fce97f92849ba21e5faa51b7845;p=fll Cleanup: Apply new script practices. This is essentially a backport of the 0.7 commit f856496d258a223eb7eb5f8fe645297e8af27b46. Be more consistent about wrapping all variables in brackets. This helps make the code more consistent and also more compatible with other interpreters like ZSH. Don't use echo pipe syntax and instead use "<<<" redirection pipe syntax for passing variables to program calls. The grep commands should use either `-sho` or `-shoP`. Add missing 'unset main' calls in some scripts. Several of the level_3 program scripts are skipped from these changes. I simply did not want to spend the time migrating those. --- diff --git a/build/scripts/bootstrap-example.sh b/build/scripts/bootstrap-example.sh index 282d986..a34963f 100644 --- a/build/scripts/bootstrap-example.sh +++ b/build/scripts/bootstrap-example.sh @@ -38,7 +38,7 @@ # This is not intended to provide any extensive or thorough error handling. # # This script can also be run under zsh rather than bash by setting the environment variable SHELL_ENGINE to "zsh", such as: -# SHELL_ENGINE="zsh" zsh ./bootstrap-example.sh --help +# SHELL_ENGINE="zsh" zsh ./bootstrap-example.sh # main() { @@ -84,7 +84,7 @@ main() { j= p= - while [[ ${i} -le $# ]] ; do + while [[ ${i} -le ${#} ]] ; do if [[ ${SHELL_ENGINE} == "zsh" ]] ; then p=${(P)i} @@ -131,7 +131,7 @@ main() { elif [[ ${p} == "-w" || ${p} == "--work" ]] ; then let i++ - if [[ ${i} -le $# ]] ; then + if [[ ${i} -le ${#} ]] ; then path_work=${p} fi fi @@ -228,7 +228,7 @@ boostrap_process() { fi # The following are examples on building individual projects. - for mode_part in fake firewutf8 ; do + for mode_part in fake firewall utf8 ; do if [[ ${1} == "${mode_part}-individual" || ${1} == "${mode_part}-level" || ${1} == "${mode_part}-monolithic" || ${1} == "${mode_part}-stand_alone" ]] ; then break; fi @@ -329,7 +329,7 @@ boostrap_process() { fi done - if [[ $skip != "" ]] ; then + if [[ ${skip} != "" ]] ; then echo "Skipping program: '${i}'." echo @@ -358,7 +358,7 @@ boostrap_process() { if [[ ${?} -ne 0 ]] ; then return 1 ; fi fi done - fi + fi done else echo diff --git a/build/scripts/bootstrap.sh b/build/scripts/bootstrap.sh index 8219279..d807f75 100644 --- a/build/scripts/bootstrap.sh +++ b/build/scripts/bootstrap.sh @@ -81,8 +81,8 @@ bootstrap_main() { local enable_shared= local enable_static= - if [[ $# -gt 0 ]] ; then - t=$# + if [[ ${#} -gt 0 ]] ; then + t=${#} while [[ ${i} -lt ${t} ]] ; do let i=${i}+1 @@ -173,16 +173,16 @@ bootstrap_main() { elif [[ ${grab_next} == "settings_name" ]] ; then settings_name="${p}" elif [[ ${grab_next} == "path_build" ]] ; then - path_build=$(echo ${p} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_build=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${p}) override_path_build="y" elif [[ ${grab_next} == "path_data" ]] ; then - path_data=$(echo ${p} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_data=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${p}) override_path_data="y" elif [[ ${grab_next} == "path_sources" ]] ; then - path_sources=$(echo ${p} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_sources=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${p}) override_path_sources="y" elif [[ ${grab_next} == "path_work" ]] ; then - path_work=$(echo ${p} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_work=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${p}) override_path_work="y" fi @@ -194,7 +194,7 @@ bootstrap_main() { fi # If the settings_name has a directory separator, then assume it is a path to the settings file. - if [[ $(echo ${settings_name} | grep -s -o '/') == "" ]] ; then + if [[ $(grep -sho '/' <<< ${settings_name}) == "" ]] ; then settings_file="${path_data}build/${settings_name}" else settings_file="${settings_name}" @@ -229,7 +229,7 @@ bootstrap_main() { # FSS and Featurless Make supports more flexible mode names, but for the purpose of this bootstrap script and avoiding potential problems, keep it simple. if [[ ${modes} != "" ]] ; then for mode in ${modes} ; do - if [[ $(echo "${mode}" | grep -s -o "[^_[:alnum:]+-]") != "" ]] ; then + if [[ $(grep -sho '[^_[:alnum:]+-]' <<< ${mode}) != "" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: The mode ${c_notice}${mode}${c_error} includes invalid characters, only alphanumeric, underscore, minus, and plus are allowed.${c_reset}" fi @@ -809,11 +809,11 @@ bootstrap_load_settings() { # Get available modes. if [[ ${modes_available} == "" ]] ; then - modes_available=$(grep -s -o "^[[:space:]]*modes[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*modes\>||" -e 's|^[[:space:]]*||') + modes_available=$(grep -sho "^[[:space:]]*modes[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*modes\>||" -e 's|^[[:space:]]*||') fi # Get default modes. - modes_default=$(grep -s -o "^[[:space:]]*modes_default[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*modes_default\>||" -e 's|^[[:space:]]*||') + modes_default=$(grep -sho "^[[:space:]]*modes_default[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*modes_default\>||" -e 's|^[[:space:]]*||') # Use default modes if no mode is explicitly provided. if [[ ${modes} == "" ]] ; then @@ -836,8 +836,8 @@ bootstrap_load_settings() { variables[${key}]="no" fi else - if [[ $(grep -s -o "^[[:space:]]*${i}[[:space:]].*\$" ${settings_file}) != "" ]] ; then - value=$(grep -s -o "^[[:space:]]*${i}[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*${i}\>||" -e 's|^[[:space:]]*||') + if [[ $(grep -sho "^[[:space:]]*${i}[[:space:]].*\$" ${settings_file}) != "" ]] ; then + value=$(grep -sho "^[[:space:]]*${i}[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*${i}\>||" -e 's|^[[:space:]]*||') variables[${key}]="${value}" key= @@ -845,7 +845,7 @@ bootstrap_load_settings() { if [[ ${key} != "" ]] ; then variables[${key}]="yes" fi - elif [[ $(grep -s -o "^[[:space:]]*${i}\$" ${settings_file}) != "" ]] ; then + elif [[ $(grep -sho "^[[:space:]]*${i}\$" ${settings_file}) != "" ]] ; then variables[${key}]="" key= @@ -879,8 +879,8 @@ bootstrap_load_settings() { variables[${key}]="no" fi else - if [[ $(grep -s -o "^[[:space:]]*${i}[[:space:]].*\$" ${settings_file}) != "" ]] ; then - value=$(grep -s -o "^[[:space:]]*${i}[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*${i}\>||" -e 's|^[[:space:]]*||') + if [[ $(grep -sho "^[[:space:]]*${i}[[:space:]].*\$" ${settings_file}) != "" ]] ; then + value=$(grep -sho "^[[:space:]]*${i}[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*${i}\>||" -e 's|^[[:space:]]*||') variables[${key}]="${variables[${key}]}${value} " key= @@ -888,7 +888,7 @@ bootstrap_load_settings() { if [[ ${key} != "" ]] ; then variables[${key}]="yes" fi - elif [[ $(grep -s -o "^[[:space:]]*${i}\$" ${settings_file}) != "" ]] ; then + elif [[ $(grep -sho "^[[:space:]]*${i}\$" ${settings_file}) != "" ]] ; then variables[${key}]="" key= @@ -932,8 +932,8 @@ bootstrap_load_settings_mode() { fi else - if [[ $(grep -s -o "^[[:space:]]*${i}-${m}[[:space:]].*\$" ${settings_file}) != "" ]] ; then - value=$(grep -s -o "^[[:space:]]*${i}-${m}[[:space:]].*\$" ${settings_file} | sed -e "H;/${i}-${m}/h;\$!d;x" | sed -e "s|^[[:space:]]*${i}-${m}\>||" -e 's|^[[:space:]]*||') + if [[ $(grep -sho "^[[:space:]]*${i}-${m}[[:space:]].*\$" ${settings_file}) != "" ]] ; then + value=$(grep -sho "^[[:space:]]*${i}-${m}[[:space:]].*\$" ${settings_file} | sed -e "H;/${i}-${m}/h;\$!d;x" | sed -e "s|^[[:space:]]*${i}-${m}\>||" -e 's|^[[:space:]]*||') variables[${key}]="${value}" key= @@ -941,7 +941,7 @@ bootstrap_load_settings_mode() { if [[ ${key} != "" ]] ; then variables[${key}]="yes" fi - elif [[ $(grep -s -o "^[[:space:]]*${i}-${m}\$" ${settings_file}) != "" ]] ; then + elif [[ $(grep -sho "^[[:space:]]*${i}-${m}\$" ${settings_file}) != "" ]] ; then variables[${key}]="" key= @@ -975,8 +975,8 @@ bootstrap_load_settings_mode() { variables[${key}]="no" fi else - if [[ $(grep -s -o "^[[:space:]]*${i}-${m}[[:space:]].*\$" ${settings_file}) != "" ]] ; then - value=$(grep -s -o "^[[:space:]]*${i}-${m}[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*${i}-${m}\>||" -e 's|^[[:space:]]*||') + if [[ $(grep -sho "^[[:space:]]*${i}-${m}[[:space:]].*\$" ${settings_file}) != "" ]] ; then + value=$(grep -sho "^[[:space:]]*${i}-${m}[[:space:]].*\$" ${settings_file} | sed -e "s|^[[:space:]]*${i}-${m}\>||" -e 's|^[[:space:]]*||') variables[${key}]="${variables[${key}]}${value} " key= @@ -984,7 +984,7 @@ bootstrap_load_settings_mode() { if [[ ${key} != "" ]] ; then variables[${key}]="yes" fi - elif [[ $(grep -s -o "^[[:space:]]*${i}-${m}\$" ${settings_file}) != "" ]] ; then + elif [[ $(grep -sho "^[[:space:]]*${i}-${m}\$" ${settings_file}) != "" ]] ; then variables[${key}]="" key= @@ -1445,7 +1445,7 @@ bootstrap_operation_build() { fi sources="${path_sources_object}${path_language}${i} " - n=$(echo $i | sed -e 's|\.[^\.]*$||') + n=$(sed -e 's|\.[^\.]*$||' <<< ${i}) if [[ ${verbosity} == "verbose" ]] ; then echo ${build_compiler} ${sources} -c -o ${path_build}objects/${path_object_shared}${n}.o ${arguments_shared} ${arguments_include} ${libraries} ${libraries_shared} ${flags} ${flags_shared} ${flags_object} ${flags_object_shared} ${defines} ${defines_shared} ${defines_object} ${defines_object_shared} ${define_extra} @@ -1551,7 +1551,7 @@ bootstrap_operation_build() { fi sources="${path_sources_object}${path_language}${i} " - n=$(echo $i | sed -e 's|\.[^\.]*$||') + n=$(sed -e 's|\.[^\.]*$||' <<< ${i}) if [[ ${verbosity} == "verbose" ]] ; then echo ${build_compiler} ${sources} -c -o ${path_build}objects/${path_object_static}${n}.o ${arguments_static} ${arguments_include} ${libraries} ${libraries_static} ${flags} ${flags_static} ${flags_object} ${flags_object_static} ${defines} ${defines_static} ${defines_object} ${defines_object_static} ${define_extra} @@ -2166,7 +2166,7 @@ bootstrap_operation_build_prepare_headers() { fi if [[ ${path_headers} != "" ]] ; then - path_headers=$(echo ${path_headers} | sed -e 's|/*$|/|') + path_headers=$(sed -e 's|/*$|/|' <<< ${path_headers}) fi } @@ -2293,7 +2293,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_sources} != "" ]] ; then - path_sources=$(echo ${path_sources} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_sources=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_sources}) fi bootstrap_id "path_sources_object-mode" @@ -2307,7 +2307,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_sources_object} != "" ]] ; then - path_sources_object=$(echo ${path_sources_object} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_sources_object=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_sources_object}) fi bootstrap_id "path_headers-mode" @@ -2316,7 +2316,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_headers} != "" ]] ; then - path_headers=$(echo ${path_headers} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_headers=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_headers}) fi bootstrap_id "has_path_standard-mode" @@ -2338,7 +2338,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_language} != "" ]] ; then - path_language=$(echo ${path_language} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_language=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_language}) fi fi @@ -2348,7 +2348,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_library} != "" ]] ; then - path_object_library=$(echo ${path_object_library} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_library=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_library}) fi bootstrap_id "path_object_program-mode" @@ -2357,7 +2357,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_program} != "" ]] ; then - path_object_program=$(echo ${path_object_program} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_program=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_program}) fi bootstrap_id "path_library_script-mode" @@ -2366,7 +2366,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_library_script} != "" ]] ; then - path_library_script=$(echo ${path_library_script} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_library_script=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_library_script}) fi bootstrap_id "path_library_shared-mode" @@ -2375,7 +2375,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_library_shared} != "" ]] ; then - path_library_shared=$(echo ${path_library_shared} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_library_shared=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_library_shared}) fi bootstrap_id "path_library_static-mode" @@ -2384,7 +2384,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_library_static} != "" ]] ; then - path_library_static=$(echo ${path_library_static} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_library_static=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_library_static}) fi bootstrap_id "path_object_library_script-mode" @@ -2393,7 +2393,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_library_script} != "" ]] ; then - path_object_library_script=$(echo ${path_object_library_script} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_library_script=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_library_script}) fi bootstrap_id "path_object_library_shared-mode" @@ -2402,7 +2402,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_library_shared} != "" ]] ; then - path_object_library_shared=$(echo ${path_object_library_shared} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_library_shared=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_library_shared}) fi bootstrap_id "path_object_library_static-mode" @@ -2411,7 +2411,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_library_static} != "" ]] ; then - path_object_library_static=$(echo ${path_object_library_static} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_library_static=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_library_static}) fi bootstrap_id "path_object_program_script-mode" @@ -2420,7 +2420,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_program_script} != "" ]] ; then - path_object_program_script=$(echo ${path_object_program_script} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_program_script=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_program_script}) fi bootstrap_id "path_object_program_shared-mode" @@ -2429,7 +2429,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_program_shared} != "" ]] ; then - path_object_program_shared=$(echo ${path_object_program_shared} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_program_shared=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_program_shared}) fi bootstrap_id "path_object_program_static-mode" @@ -2438,7 +2438,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_program_static} != "" ]] ; then - path_object_program_static=$(echo ${path_object_program_static} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_program_static=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_program_static}) fi bootstrap_id "path_object_script-mode" @@ -2447,7 +2447,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_script} != "" ]] ; then - path_object_script=$(echo ${path_object_script} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_script=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_script}) fi bootstrap_id "path_object_shared-mode" @@ -2456,7 +2456,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_shared} != "" ]] ; then - path_object_shared=$(echo ${path_object_shared} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_shared=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_shared}) fi bootstrap_id "path_object_static-mode" @@ -2465,11 +2465,11 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_object_static} != "" ]] ; then - path_object_static=$(echo ${path_object_static} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_static=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_static}) fi if [[ ${path_object_static} != "" ]] ; then - path_object_static=$(echo ${path_object_static} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_object_static=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_object_static}) fi bootstrap_id "path_program_script-mode" @@ -2478,7 +2478,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_program_script} != "" ]] ; then - path_program_script=$(echo ${path_program_script} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_program_script=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_program_script}) fi bootstrap_id "path_program_shared-mode" @@ -2487,7 +2487,7 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_program_shared} != "" ]] ; then - path_program_shared=$(echo ${path_program_shared} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_program_shared=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_program_shared}) fi bootstrap_id "path_program_static-mode" @@ -2496,11 +2496,11 @@ bootstrap_operation_build_prepare_paths() { fi if [[ ${path_program_static} != "" ]] ; then - path_program_static=$(echo ${path_program_static} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_program_static=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_program_static}) fi if [[ ${path_program_static} != "" ]] ; then - path_program_static=$(echo ${path_program_static} | sed -e 's|//*|/|g' -e 's|/*$|/|') + path_program_static=$(sed -e 's|//*|/|g' -e 's|/*$|/|' <<< ${path_program_static}) fi } @@ -2836,7 +2836,7 @@ bootstrap_operation_build_validate_shared_static() { bootstrap_operation_build_validate_sources() { for i in ${sources_script} ; do - if [[ ${i} != "$(echo ${i} | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then + if [[ ${i} != "$(sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||' <<< ${i})" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_script path provided: '${i}'.${c_reset}" fi @@ -2846,7 +2846,7 @@ bootstrap_operation_build_validate_sources() { done for i in ${sources_headers} ; do - if [[ ${i} != "$(echo ${i} | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then + if [[ ${i} != "$(sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||' <<< ${i})" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_headers path provided: '${i}'.${c_reset}" fi @@ -2856,7 +2856,7 @@ bootstrap_operation_build_validate_sources() { done for i in ${sources_library} ; do - if [[ ${i} != "$(echo ${i} | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then + if [[ ${i} != "$(sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||' <<< ${i})" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_library path provided: '${i}'.${c_reset}" fi @@ -2866,7 +2866,7 @@ bootstrap_operation_build_validate_sources() { done for i in ${sources_library_object} ; do - if [[ ${i} != "$(echo ${i} | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then + if [[ ${i} != "$(sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||' <<< ${i})" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_library_object path provided: '${i}'.${c_reset}" fi @@ -2876,7 +2876,7 @@ bootstrap_operation_build_validate_sources() { done for i in ${sources_program_object} ; do - if [[ ${i} != "$(echo ${i} | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then + if [[ ${i} != "$(sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||' <<< ${i})" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_program_object path provided: '${i}'.${c_reset}" fi @@ -2886,7 +2886,7 @@ bootstrap_operation_build_validate_sources() { done for i in ${sources_program} ; do - if [[ ${i} != "$(echo ${i} | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then + if [[ ${i} != "$(sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||' <<< ${i})" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_program path provided: '${i}'.${c_reset}" fi @@ -2896,7 +2896,7 @@ bootstrap_operation_build_validate_sources() { done for i in ${sources_documentation} ; do - if [[ ${i} != "$(echo ${i} | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then + if [[ ${i} != "$(sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||' <<< ${i})" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_documentation path provided: '${i}'.${c_reset}" fi @@ -2906,7 +2906,7 @@ bootstrap_operation_build_validate_sources() { done for i in ${sources_setting} ; do - if [[ ${i} != "$(echo ${i} | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then + if [[ ${i} != "$(sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||' <<< ${i})" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_setting path provided: '${i}'.${c_reset}" fi diff --git a/build/scripts/generate_codepoints_from_digits.sh b/build/scripts/generate_codepoints_from_digits.sh index fe7d3a4..fc6f9bb 100644 --- a/build/scripts/generate_codepoints_from_digits.sh +++ b/build/scripts/generate_codepoints_from_digits.sh @@ -11,14 +11,14 @@ main() { local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope. - local -i first="$1" - local -i last="$2" + local -i first="${1}" + local -i last="${2}" - while [[ $first -le $last ]] ; do - printf "U+%04X\n" $first + while [[ ${first} -le ${last} ]] ; do + printf "U+%04X\n" ${first} let first++ done } -main "$1" "$2" +main "${1}" "${2}" diff --git a/build/scripts/generate_ctags.sh b/build/scripts/generate_ctags.sh index c07d81a..64be5e0 100644 --- a/build/scripts/generate_ctags.sh +++ b/build/scripts/generate_ctags.sh @@ -48,8 +48,8 @@ main() { local verbose= local verbose_common= - if [[ $# -gt 0 ]] ; then - t=$# + if [[ ${#} -gt 0 ]] ; then + t=${#} while [[ ${i} -lt ${t} ]] ; do let i=${i}+1 @@ -106,9 +106,9 @@ main() { fi else if [[ ${grab_next} == "destination" ]] ; then - destination=$(echo ${p} | sed -e 's|$|/|' -e 's|//*|/|g') + destination=$(sed -e 's|$|/|' -e 's|//*|/|g' <<< ${p}) elif [[ ${grab_next} == "source" ]] ; then - source=$(echo ${p} | sed -e 's|$|/|' -e 's|//*|/|g') + source=$(sed -e 's|$|/|' -e 's|//*|/|g' <<< ${p}) fi grab_next= @@ -134,7 +134,7 @@ main() { return 0 fi - if [[ $(echo "$name" | grep -s -o "/") != "" || ${name} == "" ]] ; then + if [[ $(grep -sho "/" <<< ${name}) != "" || ${name} == "" ]] ; then if [[ ${verbosity} != "quiet" ]] ; then if [[ ${name} == "" ]] ; then echo -e "${c_error}ERROR: No ${c_notice}name${c_error} parameter has been provided or is empty.${c_reset}" @@ -185,7 +185,7 @@ main() { find -L ${source} -not -path '*/\.*' \( -name '*.h' \) | ctags -n --fields=EfiklsZSt --extras=-f --c-kinds=+p -L - -f "${file}" --tag-relative=never --language-force=c - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: The ${c_notice}ctags${c_error} process failed.${c_reset}" fi @@ -203,7 +203,7 @@ main() { sed -i -e "s|${source}||g" "${file}" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then if [[ ${verbosity} != "quiet" ]] ; then echo -e "${c_error}ERROR: Failed to strip the full path from the ${c_notice}${file}${c_error} file.${c_reset}" fi diff --git a/build/scripts/generate_unicode.sh b/build/scripts/generate_unicode.sh index b339669..cb541ca 100644 --- a/build/scripts/generate_unicode.sh +++ b/build/scripts/generate_unicode.sh @@ -14,7 +14,7 @@ main() { local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope. local file_input="codes.txt" - local mode=$1 + local mode=${1} local code= local sequence= local block= @@ -29,36 +29,36 @@ main() { local u3= local -i i=0 - if [[ $mode == "" ]] ; then + if [[ ${mode} == "" ]] ; then mode=source - elif [[ ! ($mode == "source" || $mode == "test") ]] ; then + elif [[ ! (${mode} == "source" || ${mode} == "test") ]] ; then - # return on invalid parameter. + # Return on invalid parameter. return 1 fi - for code in $(cat $file_input) ; do + for code in $(cat ${file_input}) ; do process - if [[ "$previous" == "" || "$block" == "$previous" ]] ; then - if [[ $i -eq 0 ]] ; then - s0=$sequence - u0=$code + if [[ "${previous}" == "" || "${block}" == "${previous}" ]] ; then + if [[ ${i} -eq 0 ]] ; then + s0=${sequence} + u0=${code} let i++ - elif [[ $i -eq 1 ]] ; then - s1=$sequence - u1=$code + elif [[ ${i} -eq 1 ]] ; then + s1=${sequence} + u1=${code} let i++ - elif [[ $i -eq 2 ]] ; then - s2=$sequence - u2=$code + elif [[ ${i} -eq 2 ]] ; then + s2=${sequence} + u2=${code} let i++ else - s3=$sequence - u3=$code + s3=${sequence} + u3=${code} - generate "$block" + generate "${block}" s0= s1= @@ -73,16 +73,16 @@ main() { let i=0 fi else - if [[ $i -gt 0 ]] ; then - generate "$previous" + if [[ ${i} -gt 0 ]] ; then + generate "${previous}" fi - s0=$sequence + s0=${sequence} s1= s2= s3= - u0=$code + u0=${code} u1= u2= u3= @@ -90,89 +90,89 @@ main() { let i=1 fi - previous="$block" + previous="${block}" done - if [[ $s0 != "" ]] ; then - generate "$previous" + if [[ ${s0} != "" ]] ; then + generate "${previous}" fi } process() { - local utf8=$(unicode --color=0 $code | grep -o "^UTF-8:.*UTF-16BE:" | sed -e 's|UTF-8:||' -e 's|UTF-16BE:||' | sed -e 's| ||g') + local utf8=$(unicode --color=0 ${code} | grep -sho "^UTF-8:.*UTF-16BE:" | sed -e 's|UTF-8:||' -e 's|UTF-16BE:||' | sed -e 's| ||g') - block=$(unicode --color=0 $code | grep -o "^Unicode block: .*$" | sed -e 's|Unicode block:.*; ||') + block=$(unicode --color=0 ${code} | grep -sho "^Unicode block: .*$" | sed -e 's|Unicode block:.*; ||') - if [[ $mode == "source" ]] ; then - sequence="0x$utf8" + if [[ ${mode} == "source" ]] ; then + sequence="0x${utf8}" - if [[ $(echo -n "$utf8" | wc -c) -eq 2 ]] ; then + if [[ $(wc -c <<< ${utf8}) -eq 2 ]] ; then sequence="${sequence}000000" - elif [[ $(echo -n "$utf8" | wc -c) -eq 4 ]] ; then + elif [[ $(wc -c <<< ${utf8}) -eq 4 ]] ; then sequence="${sequence}0000" - elif [[ $(echo -n "$utf8" | wc -c) -eq 6 ]] ; then + elif [[ $(wc -c <<< ${utf8}) -eq 6 ]] ; then sequence="${sequence}00" fi - elif [[ $mode == "test" ]] ; then - sequence="$utf8" + elif [[ ${mode} == "test" ]] ; then + sequence="${utf8}" fi } generate() { - if [[ $mode == "source" ]] ; then - generate_source "$1" - elif [[ $mode == "test" ]] ; then - generate_test "$1" + if [[ ${mode} == "source" ]] ; then + generate_source "${1}" + elif [[ ${mode} == "test" ]] ; then + generate_test "${1}" fi } generate_source() { local comment= local condition= - local block="$1" + local block="${1}" - if [[ $u3 == "" ]] ; then - if [[ $u2 == "" ]] ; then - if [[ $u1 == "" ]] ; then - comment="$u0" - condition="character == $s0" + if [[ ${u3} == "" ]] ; then + if [[ ${u2} == "" ]] ; then + if [[ ${u1} == "" ]] ; then + comment="${u0}" + condition="character == ${s0}" else - comment="$u0, $u1" - condition="character == $s0 || character == $s1" + comment="${u0}, ${u1}" + condition="character == ${s0} || character == ${s1}" fi else - comment="$u0, $u1, $u2" - condition="character == $s0 || character == $s1 || character == $s2" + comment="${u0}, ${u1}, ${u2}" + condition="character == ${s0} || character == ${s1} || character == ${s2}" fi else - comment="$u0, $u1, $u2, $u3" - condition="character == $s0 || character == $s1 || character == $s2 || character == $s3" + comment="${u0}, ${u1}, ${u2}, ${u3}" + condition="character == ${s0} || character == ${s1} || character == ${s2} || character == ${s3}" fi echo - echo "// $block: $comment." - echo "if ($condition) {" + echo "// ${block}: ${comment}." + echo "if (${condition}) {" echo " return F_true;" echo "}" } generate_test() { - if [[ $s0 != "" ]] ; then - printf "%llu\n" $((16#$s0)) + if [[ ${s0} != "" ]] ; then + printf "%llu\n" $((16#${s0})) fi - if [[ $s1 != "" ]] ; then - printf "%llu\n" $((16#$s1)) + if [[ ${s1} != "" ]] ; then + printf "%llu\n" $((16#${s1})) fi - if [[ $s2 != "" ]] ; then - printf "%llu\n" $((16#$s2)) + if [[ ${s2} != "" ]] ; then + printf "%llu\n" $((16#${s2})) fi - if [[ $s3 != "" ]] ; then - printf "%llu\n" $((16#$s3)) + if [[ ${s3} != "" ]] ; then + printf "%llu\n" $((16#${s3})) fi } -main "$1" +main "${1}" diff --git a/build/scripts/install.sh b/build/scripts/install.sh index e0cf853..72ccfac 100644 --- a/build/scripts/install.sh +++ b/build/scripts/install.sh @@ -83,8 +83,8 @@ install_main() { local enable_static_libraries="yes" local enable_includes="yes" - if [[ $# -gt 0 ]] ; then - t=$# + if [[ ${#} -gt 0 ]] ; then + t=${#} while [[ ${i} -lt ${t} ]] ; do let i=${i}+1 @@ -190,29 +190,29 @@ install_main() { fi else if [[ ${grab_next} == "path_build" ]] ; then - path_build=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + path_build=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "prefix" ]] ; then - destination_prefix=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_prefix=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "bindir" ]] ; then - destination_programs=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_programs=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "docdir" ]] ; then - destination_documentation=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_documentation=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "etcdir" ]] ; then - destination_settings=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_settings=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "includedir" ]] ; then - destination_includes=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_includes=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "libdir" ]] ; then - destination_libraries=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_libraries=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "work" ]] ; then - work=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + work=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "destination_libraries_static" ]] ; then - destination_libraries_static=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_libraries_static=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "destination_libraries_shared" ]] ; then - destination_libraries_shared=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_libraries_shared=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "destination_programs_static" ]] ; then - destination_programs_static=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_programs_static=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "destination_programs_shared" ]] ; then - destination_programs_shared=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + destination_programs_shared=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) fi grab_next= @@ -269,29 +269,29 @@ install_main() { fi if [[ ${destination_prefix} != "" ]] ; then - if [[ $(echo ${destination_documentation} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_documentation}) == "" ]] ; then destination_documentation="${destination_prefix}${destination_documentation}" fi - if [[ $(echo ${destination_programs} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_programs}) == "" ]] ; then destination_programs="${destination_prefix}${destination_programs}" fi - if [[ $(echo ${destination_includes} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_includes}) == "" ]] ; then destination_includes="${destination_prefix}${destination_includes}" fi - if [[ $(echo ${destination_libraries} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_libraries}) == "" ]] ; then destination_libraries="${destination_prefix}${destination_libraries}" fi - if [[ $(echo ${destination_settings} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_settings}) == "" ]] ; then destination_settings="${destination_prefix}${destination_settings}" fi fi if [[ ${destination_libraries_static} != "" ]] ; then - if [[ $(echo ${destination_libraries_static} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_libraries_static}) == "" ]] ; then destination_libraries_static=${destination_libraries}${destination_libraries_static} fi else @@ -299,7 +299,7 @@ install_main() { fi if [[ ${destination_libraries_shared} != "" ]] ; then - if [[ $(echo ${destination_libraries_shared} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_libraries_shared}) == "" ]] ; then destination_libraries_shared=${destination_libraries}${destination_libraries_shared} fi else @@ -307,7 +307,7 @@ install_main() { fi if [[ ${destination_programs_static} != "" ]] ; then - if [[ $(echo ${destination_programs_static} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_programs_static}) == "" ]] ; then destination_programs_static=${destination_programs}${destination_programs_static} fi else @@ -315,7 +315,7 @@ install_main() { fi if [[ ${destination_programs_shared} != "" ]] ; then - if [[ $(echo ${destination_programs_shared} | grep -o '^/') == "" ]] ; then + if [[ $(grep -sho '^/' <<< ${destination_programs_shared}) == "" ]] ; then destination_programs_shared=${destination_programs}${destination_programs_shared} fi else @@ -650,7 +650,7 @@ install_perform_install() { if [[ ${failure} -eq 0 && -d ${path_build}${path_includes} && ${enable_includes} == "yes" ]] ; then for i in ${path_build}${path_includes}* ; do - file=$(echo ${i} | sed -e "s|^${path_build}${path_includes}||") + file=$(sed -e "s|^${path_build}${path_includes}||" <<< ${i}) break done @@ -681,7 +681,7 @@ install_perform_install() { if [[ -d ${path_build}${path_libraries}${path_static} && ${enable_static_libraries} == "yes" ]] ; then for i in ${path_build}${path_libraries}${path_static}* ; do - file=$(echo ${i} | sed -e "s|^${path_build}${path_libraries}${path_static}||") + file=$(sed -e "s|^${path_build}${path_libraries}${path_static}||" <<< ${i}) break done @@ -711,7 +711,7 @@ install_perform_install() { if [[ ${failure} -eq 0 && -d ${path_build}${path_libraries}${path_shared} && ${enable_shared_libraries} == "yes" ]] ; then for i in ${path_build}${path_libraries}${path_shared}* ; do - file=$(echo ${i} | sed -e "s|^${path_build}${path_libraries}${path_shared}||") + file=$(sed -e "s|^${path_build}${path_libraries}${path_shared}||" <<< ${i}) break done @@ -743,7 +743,7 @@ install_perform_install() { if [[ -d ${path_build}${path_programs}${path_static} && ${enable_static_programs} == "yes" ]] ; then for i in ${path_build}${path_programs}${path_static}* ; do - file=$(echo ${i} | sed -e "s|^${path_build}${path_programs}${path_static}||") + file=$(sed -e "s|^${path_build}${path_programs}${path_static}||" <<< ${i}) break done @@ -773,7 +773,7 @@ install_perform_install() { if [[ ${failure} -eq 0 && -d ${path_build}${path_programs}${path_shared} && ${enable_shared_programs} == "yes" ]] ; then for i in ${path_build}${path_programs}${path_shared}* ; do - file=$(echo ${i} | sed -e "s|^${path_build}${path_programs}${path_shared}||") + file=$(sed -e "s|^${path_build}${path_programs}${path_shared}||" <<< ${i}) break done @@ -804,7 +804,7 @@ install_perform_install() { if [[ ${failure} -eq 0 && -d ${path_build}${path_settings} && ${enable_settings} == "yes" ]] ; then for i in ${path_build}${path_settings}* ; do - file=$(echo ${i} | sed -e "s|^${path_build}${path_settings}||") + file=$(sed -e "s|^${path_build}${path_settings}||" <<< ${i}) break done @@ -834,7 +834,7 @@ install_perform_install() { if [[ ${failure} -eq 0 && -d ${path_build}${path_documentation} && ${enable_documentation} == "yes" ]] ; then for i in ${path_build}${path_documentation}* ; do - file=$(echo ${i} | sed -e "s|^${path_build}${path_documentation}||") + file=$(sed -e "s|^${path_build}${path_documentation}||" <<< ${i}) break done diff --git a/build/scripts/package.sh b/build/scripts/package.sh index 3ec93d3..fd44e16 100644 --- a/build/scripts/package.sh +++ b/build/scripts/package.sh @@ -20,7 +20,7 @@ package_main() { local public_name="Simple FLL Project Package Script" local system_name=package - local called_name=$(basename $0) + local called_name=$(basename ${0}) local version=0.6.14 local grab_next= @@ -59,8 +59,8 @@ package_main() { local verbose_common= local result= - if [[ $# -gt 0 ]] ; then - t=$# + if [[ ${#} -gt 0 ]] ; then + t=${#} while [[ ${i} -lt ${t} ]] ; do let i=${i}+1 @@ -106,7 +106,7 @@ package_main() { verbose="+D" verbose_common="-v" elif [[ ${p} == "+v" || ${p} == "++version" ]] ; then - echo $version + echo ${version} return 0 elif [[ ${p} == "-b" || ${p} == "--build" ]] ; then grab_next=path_build @@ -134,17 +134,17 @@ package_main() { fi else if [[ ${grab_next} == "path_build" ]] ; then - path_build=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + path_build=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "path_destination" ]] ; then - path_destination=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + path_destination=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "path_sources" ]] ; then - path_sources=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + path_sources=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) elif [[ ${grab_next} == "stand_alone" ]] ; then mode_stand_alone="${mode_stand_alone}${p} " elif [[ ${grab_next} == "prepend" ]] ; then # Provide a bare minimal sanitizer that probably doesn't catch everything that it ideally should. - prepend=$(echo ${p} | sed -e 's|[\!~\`@#$%^&*();:>") != "" ]] ; then + if [[ $(grep -sho "\" <<< ${dependencies}) != "" ]] ; then has_thread="yes" fi - for dependency in $dependencies ; do + for dependency in ${dependencies} ; do - if [[ $(echo "${dependency}" | grep -o "^f_") != "" ]] ; then + if [[ $(grep -sho "^f_" <<< ${dependency}) != "" ]] ; then level=level_0 - elif [[ $(echo "${dependency}" | grep -o "^fl_") != "" ]] ; then + elif [[ $(grep -sho "^fl_" <<< ${dependency}) != "" ]] ; then level=level_1 - elif [[ $(echo "${dependency}" | grep -o "^fll_") != "" ]] ; then + elif [[ $(grep -sho "^fll_" <<< ${dependency}) != "" ]] ; then level=level_2 else if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then @@ -704,11 +704,11 @@ package_dependencies_individual() { sub_dependencies=$(cat ${path_sources}${level}/${dependency}/data/build/dependencies | sed -e "/^\s*#/d" -e "s|#\.*$||") fi - for sub_dependency in $sub_dependencies ; do + for sub_dependency in ${sub_dependencies} ; do - if [[ $(echo "${sub_dependency}" | grep -o "^f_") != "" ]] ; then + if [[ $(grep -sho "^f_" <<< ${sub_dependency}) != "" ]] ; then sub_level=level_0 - elif [[ $(echo "${sub_dependency}" | grep -o "^fl_") != "" ]] ; then + elif [[ $(grep -sho "^fl_" <<< ${sub_dependency}) != "" ]] ; then sub_level=level_1 else if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then @@ -733,9 +733,9 @@ package_dependencies_individual() { sub_sub_dependencies=$(cat ${path_sources}${sub_level}/${sub_dependency}/data/build/dependencies | sed -e "/^\s*#/d" -e "s|#\.*$||") fi - for sub_sub_dependency in $sub_sub_dependencies ; do + for sub_sub_dependency in ${sub_sub_dependencies} ; do - if [[ $(echo "${sub_sub_dependency}" | grep -o "^f_") != "" ]] ; then + if [[ $(grep -sho "^f_" <<< ${sub_sub_dependency}) != "" ]] ; then sub_sub_level=level_0 else if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then @@ -778,7 +778,7 @@ package_dependencies_individual() { break; fi - dependencies_individual=$(echo "${dependencies_individual}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' -e 's|[[:space:]][[:space:]]*$| |') + dependencies_individual=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' -e 's|[[:space:]][[:space:]]*$| |' <<< ${dependencies_individual}) if [[ ${dependencies_individual} != "" ]] ; then if [[ ${verbosity} == "verbose" ]] ; then echo -e " ${dependencies_individual}" @@ -844,8 +844,8 @@ package_dependencies_individual() { } package_dependencies_individual_append() { - local level="$1" - local dependency="$2" + local level="${1}" + local dependency="${2}" local settings= local libraries= @@ -860,10 +860,10 @@ package_dependencies_individual_append() { return 1 fi - libraries=$(grep -o '^\s*build_sources_library\s.*$' ${settings} | sed -e 's|^\s*build_sources_library\>||' -e 's|^\s*||' -e 's|\s*$||') + libraries=$(grep -sho '^\s*build_sources_library\s.*$' ${settings} | sed -e 's|^\s*build_sources_library\>||' -e 's|^\s*||' -e 's|\s*$||') - if [[ $libraries != "" ]] ; then - if [[ $(echo -n ${dependencies_individual} | grep -o "\-l${dependency}\>") == "" ]] ; then + if [[ ${libraries} != "" ]] ; then + if [[ $(grep -sho "\-l${dependency}\>" <<< ${dependencies_individual}) == "" ]] ; then if [[ "$(type -p sort)" != "" ]] ; then if [[ ${level} == "level_0" ]] ; then @@ -941,8 +941,8 @@ package_dependencies_level() { } package_dependencies_level_update() { - local level="$1" - local level_libraries="$2" + local level="${1}" + local level_libraries="${2}" local level_sources_library= local level_sources_headers= local level_sources_library_threaded= @@ -959,7 +959,7 @@ package_dependencies_level_update() { for directory in ${path_sources}${level}/* ; do - name="$(echo ${directory} | sed -e "s|${path_sources}${level}/||")" + name="$(sed -e "s|${path_sources}${level}/||" <<< ${directory})" settings=${directory}/data/build/settings if [[ ! -f ${settings} ]] ; then @@ -972,28 +972,28 @@ package_dependencies_level_update() { return 1 fi - libraries=$(grep -o '^\s*build_sources_library\s.*$' ${settings} | sed -e 's|^\s*build_sources_library\>||' -e 's|^\s*||' -e 's|\s*$||') + libraries=$(grep -sho '^\s*build_sources_library\s.*$' ${settings} | sed -e 's|^\s*build_sources_library\>||' -e 's|^\s*||' -e 's|\s*$||') - for library in $libraries ; do + for library in ${libraries} ; do if [[ ${name} == "f_thread" ]] ; then - level_sources_library_threaded="${level_sources_library_threaded} $library" + level_sources_library_threaded="${level_sources_library_threaded} ${library}" monolithic_libraries_threaded="${monolithic_libraries_threaded} ${level}/${library}" else - level_sources_library="${level_sources_library} $library" + level_sources_library="${level_sources_library} ${library}" monolithic_libraries="${monolithic_libraries} ${level}/${library}" fi done - headers=$(grep -o '^\s*build_sources_headers\s.*$' ${settings} | sed -e 's|^\s*build_sources_headers\>||' -e 's|^\s*||' -e 's|\s*$||') + headers=$(grep -sho '^\s*build_sources_headers\s.*$' ${settings} | sed -e 's|^\s*build_sources_headers\>||' -e 's|^\s*||' -e 's|\s*$||') - for header in $headers ; do + for header in ${headers} ; do if [[ ${name} == "f_thread" ]] ; then - level_sources_headers_threaded="${level_sources_headers_threaded} $header" + level_sources_headers_threaded="${level_sources_headers_threaded} ${header}" monolithic_headers_threaded="${monolithic_headers_threaded} ${level}/${header}" else - level_sources_headers="${level_sources_headers} $header" + level_sources_headers="${level_sources_headers} ${header}" monolithic_headers="${monolithic_headers} ${level}/${header}" fi done @@ -1024,7 +1024,7 @@ package_dependencies_level_update() { return 1 fi - level_sources_library=$(echo "${level_sources_library}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') + level_sources_library=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${level_sources_library}) if [[ ${level_sources_library} != "" ]] ; then echo " ${level_sources_library}" level_sources_library=" ${level_sources_library}" @@ -1045,7 +1045,7 @@ package_dependencies_level_update() { return 1 fi - level_sources_headers=$(echo "${level_sources_headers}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') + level_sources_headers=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${level_sources_headers}) if [[ ${level_sources_headers} != "" ]] ; then echo " ${level_sources_headers}" level_sources_headers=" ${level_sources_headers}" @@ -1067,23 +1067,23 @@ package_dependencies_level_update() { fi if [[ ${level} == "level_0" ]] ; then - level_0_libraries=$(echo "${monolithic_libraries}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') - level_0_headers=$(echo "${monolithic_headers}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') + level_0_libraries=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_libraries}) + level_0_headers=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_headers}) - level_0_libraries_threaded=$(echo "${monolithic_libraries_threaded}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') - level_0_headers_threaded=$(echo "${monolithic_headers_threaded}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') + level_0_libraries_threaded=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_libraries_threaded}) + level_0_headers_threaded=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_headers_threaded}) elif [[ ${level} == "level_1" ]] ; then - level_1_libraries=$(echo "${monolithic_libraries}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') - level_1_headers=$(echo "${monolithic_headers}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') + level_1_libraries=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_libraries}) + level_1_headers=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_headers}) - level_1_libraries_threaded=$(echo "${monolithic_libraries_threaded}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') - level_1_headers_threaded=$(echo "${monolithic_headers_threaded}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') + level_1_libraries_threaded=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_libraries_threaded}) + level_1_headers_threaded=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_headers_threaded}) elif [[ ${level} == "level_2" ]] ; then - level_2_libraries=$(echo "${monolithic_libraries}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') - level_2_headers=$(echo "${monolithic_headers}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') + level_2_libraries=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_libraries}) + level_2_headers=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_headers}) - level_2_libraries_threaded=$(echo "${monolithic_libraries_threaded}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') - level_2_headers_threaded=$(echo "${monolithic_headers_threaded}" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') + level_2_libraries_threaded=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_libraries_threaded}) + level_2_headers_threaded=$(sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||' <<< ${monolithic_headers_threaded}) fi return 0 @@ -1499,16 +1499,16 @@ package_operation_create_config_stubs() { local language= - if [[ $(grep -soP '^\s*\bbuild_language\b\s+c\s*$' ${package}data/build/settings) != "" ]] ; then + if [[ $(grep -shoP '^\s*\bbuild_language\b\s+c\s*$' ${package}data/build/settings) != "" ]] ; then language="c" - elif [[ $(grep -soP '^\s*\bbuild_language\b\s+c\+\+\s*$' ${package}data/build/settings) != "" ]] ; then + elif [[ $(grep -shoP '^\s*\bbuild_language\b\s+c\+\+\s*$' ${package}data/build/settings) != "" ]] ; then language="c++" else return 0 fi if [[ ${language} == "c" && ! -f ${package}sources/c/config.c ]] ; then - if [[ $(grep -soP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" ]] ; then + if [[ $(grep -shoP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" ]] ; then sed -i -E -e "s|^\s*\bbuild_sources_program\s+|&config.c |" ${package}data/build/settings if [[ ${?} -ne 0 ]] ; then @@ -1520,7 +1520,7 @@ package_operation_create_config_stubs() { return ${failure} fi - elif [[ $(grep -soP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then + elif [[ $(grep -shoP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then sed -i -E -e "s|^\s*\bbuild_sources_library\s+|&config.c |" ${package}data/build/settings if [[ ${?} -ne 0 ]] ; then @@ -1534,7 +1534,7 @@ package_operation_create_config_stubs() { fi fi - if [[ $(grep -soP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" || $(grep -soP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then + if [[ $(grep -shoP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" || $(grep -shoP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then echo > ${package}sources/c/config.c && echo "#include \"config.h\"" >> ${package}sources/c/config.c @@ -1549,7 +1549,7 @@ package_operation_create_config_stubs() { fi fi elif [[ ${language} == "c++" && ! -f ${package}sources/c/config.cpp ]] ; then - if [[ $(grep -soP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" ]] ; then + if [[ $(grep -shoP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" ]] ; then sed -i -E -e "s|^\s*\bbuild_sources_program\s+|&config.cpp |" ${package}data/build/settings if [[ ${?} -ne 0 ]] ; then @@ -1561,7 +1561,7 @@ package_operation_create_config_stubs() { return ${failure} fi - elif [[ $(grep -soP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then + elif [[ $(grep -shoP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then sed -i -E -e "s|^\s*\bbuild_sources_library\s+|&config.cpp |" ${package}data/build/settings if [[ ${?} -ne 0 ]] ; then @@ -1575,7 +1575,7 @@ package_operation_create_config_stubs() { fi fi - if [[ $(grep -soP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" || $(grep -soP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then + if [[ $(grep -shoP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" || $(grep -shoP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then echo > ${package}sources/c++/config.cpp && echo "#include \"config.h\"" >> ${package}sources/c++/config.cpp @@ -1592,7 +1592,7 @@ package_operation_create_config_stubs() { fi if [[ ( ${language} == "c" && ! -f ${package}sources/c/config.h ) || ( ${language} == "c++" && ! -f ${package}sources/c++/config.h ) ]] ; then - if [[ $(grep -soP '^\s*\bbuild_language\b\s+c\s*$' ${package}data/build/settings) != "" ]] ; then + if [[ $(grep -shoP '^\s*\bbuild_language\b\s+c\s*$' ${package}data/build/settings) != "" ]] ; then echo > ${package}sources/c/config.h if [[ ${?} -ne 0 ]] ; then @@ -1666,7 +1666,7 @@ package_operation_individual() { for directory in ${path_sources}level_0/* ${path_sources}level_1/* ${path_sources}level_2/* ; do - name="$(echo ${directory} | sed -e "s|${path_sources}level_0/||" -e "s|${path_sources}level_1/||" -e "s|${path_sources}level_2/||")" + name="$(sed -e "s|${path_sources}level_0/||" -e "s|${path_sources}level_1/||" -e "s|${path_sources}level_2/||" <<< ${directory})" package="${path_destination}individual/${prepend}${name}-${version}/" if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then @@ -2133,7 +2133,7 @@ package_operation_program() { for directory in ${path_sources}level_3/* ; do - name="$(echo ${directory} | sed -e "s|${path_sources}level_3/||")" + name="$(sed -e "s|${path_sources}level_3/||" <<< ${directory})" package="${path_destination}program/${prepend}${name}-${version}/" if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then @@ -2278,14 +2278,14 @@ package_operation_stand_alone() { # Copy all sources into a named sub-directory. for path_ in ${package}sources/* ; do - path_name="$(basename $path_)" + path_name="$(basename ${path_})" for path_sub in ${package}sources/${path_name}/* ; do path_name_sub="$(basename ${path_sub})" # Do not attempt copying into self. - if [[ $path_name_sub == "program" ]] ; then + if [[ ${path_name_sub} == "program" ]] ; then continue fi @@ -2340,7 +2340,7 @@ package_operation_stand_alone() { fi if [[ -f ${package}data/build/dependencies ]] ; then - packages=$(grep -soP '^\s*[^\s]+' ${package}data/build/dependencies | sed -e 's|^[[:space:]]*||g') + packages=$(grep -shoP '^\s*[^\s]+' ${package}data/build/dependencies | sed -e 's|^[[:space:]]*||g') if [[ ${packages} != "" ]] ; then for package_sub in ${packages} ; do diff --git a/build/scripts/test.sh b/build/scripts/test.sh index 99b9ea0..13257d4 100644 --- a/build/scripts/test.sh +++ b/build/scripts/test.sh @@ -15,7 +15,6 @@ test_main() { local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope. - local shell_command=bash if [[ ${SHELL_ENGINE} == "zsh" ]] ; then @@ -77,8 +76,8 @@ test_main() { local projects_no_tests="f_type" local programs="fss_basic_read fss_extended_read fss_basic_list_read fss_extended_list_read fss_payload_read" - if [[ $# -gt 0 ]] ; then - t=$# + if [[ ${#} -gt 0 ]] ; then + t=${#} while [[ ${i} -lt ${t} ]] ; do @@ -156,10 +155,10 @@ test_main() { if [[ ${grab_next} == "build_compiler" ]] ; then build_compiler=${p} elif [[ ${grab_next} == "path_scripts" ]] ; then - path_scripts=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + path_scripts=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) path_scripts_package=${path_scripts}package.sh elif [[ ${grab_next} == "path_test" ]] ; then - path_test=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') + path_test=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${p}) path_test_package=${path_test}package/ path_test_package_individual=${path_test_package}individual/ path_test_package_program=${path_test_package}program/ @@ -290,7 +289,7 @@ test_main() { if [[ ${failure} -eq 0 ]] ; then test_operate - let failure=$? + let failure=${?} fi test_cleanup @@ -599,6 +598,7 @@ test_operate_build_project() { fi if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then + echo echo -e "Installing ${mode} project '${c_notice}${project}${c_reset}'." echo fi @@ -737,9 +737,10 @@ test_operate_ci_pretest_cmocka() { local cmocka_path="${path_test}cmocka/" local cmocka_build="${cmocka_path}build/" local cmocka_data="${cmocka_path}data/build/" - local cmocka_settings="${path_original}level_3/fake/data/projects/cmocka/1.1.5/settings" + local cmocka_version="1.1.7" + local cmocka_settings="${path_original}level_3/fake/data/projects/cmocka/${cmocka_version}/settings" local cmocka_uri="https://github.com/coreboot/cmocka.git" - local cmocka_branch="cmocka-1.1.5" + local cmocka_branch="cmocka-${cmocka_version}" if [[ -d ${cmocka_path} ]] ; then if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then @@ -753,7 +754,7 @@ test_operate_ci_pretest_cmocka() { echo "git clone ${clone_quiet} --single-branch -b ${cmocka_branch} \"${cmocka_uri}\" ${cmocka_path}" fi - git clone ${clone_quiet} --single-branch -b ${cmocka_branch} "${cmocka_uri}" ${cmocka_path} + git clone ${clone_quiet} --single-branch -b ${cmocka_branch} ${cmocka_uri} ${cmocka_path} if [[ ${?} -ne 0 ]] ; then if [[ ${verbosity} != "quiet" ]] ; then @@ -1009,7 +1010,7 @@ test_operate_tests_projects() { if [[ ${failure} -eq 0 ]] ; then if [[ ! -f ${path_test_package_individual}${project}-${version}/data/build/testfile ]] ; then - if [[ $(echo ${projects_no_tests} | grep -o "\<${project}\>") == "" ]] ; then + if [[ $(grep -sho "\<${project}\>" <<< ${projects_no_tests}) == "" ]] ; then if [[ ${verbosity} == "verbose" || ${verbosity} == "debug" ]] ; then echo -e "${c_warning}WARNING: Project '${c_notice}${project}${c_warning}' does not have a testfile.${c_reset}" fi diff --git a/level_3/fake/data/build/process_post.sh b/level_3/fake/data/build/process_post.sh index 286beff..3485327 100755 --- a/level_3/fake/data/build/process_post.sh +++ b/level_3/fake/data/build/process_post.sh @@ -16,7 +16,7 @@ process_post_main() { local p= local t=0 - # custom color codes. + # Custom color codes. local c_reset="\\033[0m" local c_title="\\033[1;33m" local c_error="\\033[1;31m" @@ -27,7 +27,7 @@ process_post_main() { local c_subtle="\\033[1;30m" local c_prefix="\\" - # the supported parameters. + # The supported parameters. local operation= local defines= local modes= @@ -39,7 +39,7 @@ process_post_main() { local path_work= local verbosity=normal - # generated paths and standard paths. + # Generated paths and standard paths. local path_directory_separator="/" local path_data_build= local path_documents="documents/" @@ -57,12 +57,12 @@ process_post_main() { local path_work_programs_shared= local path_work_programs_static= - # generated file paths. + # Generated file paths. local file_data_build_dependencies= local file_data_build_settings= local file_documents_readme= - # standard build paths. + # Standard build paths. local path_build_documents= local path_build_includes= local path_build_libraries= @@ -77,87 +77,88 @@ process_post_main() { local path_build_programs_static= local path_build_settings= - # grab all supported parameters, ignoring duplicates. - if [[ $# -gt 0 ]] ; then - t=$# + # Grab all supported parameters, ignoring duplicates. + if [[ ${#} -gt 0 ]] ; then + t=${#} - while [[ $i -lt $t ]] ; do - let i=$i+1 + while [[ ${i} -lt ${t} ]] ; do + + let i++ p="${!i}" - if [[ $grab_next == "" ]] ; then - if [[ $p == "build" || $p == "clean" || $p == "make" || $p == "skeleton" ]] ; then - if [[ $operation == "" ]] ; then - operation=$p + if [[ ${grab_next} == "" ]] ; then + if [[ ${p} == "build" || ${p} == "clean" || ${p} == "make" || ${p} == "skeleton" ]] ; then + if [[ ${operation} == "" ]] ; then + operation=${p} fi - elif [[ $p == "-d" || $p == "--define" ]] ; then + elif [[ ${p} == "-d" || ${p} == "--define" ]] ; then grab_next="defines" - elif [[ $p == "-m" || $p == "--mode" ]] ; then + elif [[ ${p} == "-m" || ${p} == "--mode" ]] ; then grab_next="modes" - elif [[ $p == "-p" || $p == "--process" ]] ; then + elif [[ ${p} == "-p" || ${p} == "--process" ]] ; then grab_next="process" - elif [[ $p == "-s" || $p == "--settings" ]] ; then + elif [[ ${p} == "-s" || ${p} == "--settings" ]] ; then grab_next="file_settings" - elif [[ $p == "-b" || $p == "--build" ]] ; then + elif [[ ${p} == "-b" || ${p} == "--build" ]] ; then grab_next="path_build" - elif [[ $p == "-D" || $p == "--data" ]] ; then + elif [[ ${p} == "-D" || ${p} == "--data" ]] ; then grab_next="path_data" - elif [[ $p == "-S" || $p == "--sources" ]] ; then + elif [[ ${p} == "-S" || ${p} == "--sources" ]] ; then grab_next="path_sources" - elif [[ $p == "-w" || $p == "--work" ]] ; then + elif [[ ${p} == "-w" || ${p} == "--work" ]] ; then grab_next="path_work" - elif [[ $p == "+D" || $p == "++debug" ]] ; then + elif [[ ${p} == "+D" || ${p} == "++debug" ]] ; then verbosity=debug - elif [[ $p == "+E" || $p == "++error" ]] ; then + elif [[ ${p} == "+E" || ${p} == "++error" ]] ; then verbosity=error - elif [[ $p == "+N" || $p == "++normal" ]] ; then + elif [[ ${p} == "+N" || ${p} == "++normal" ]] ; then verbosity=normal - elif [[ $p == "+Q" || $p == "++quiet" ]] ; then + elif [[ ${p} == "+Q" || ${p} == "++quiet" ]] ; then verbosity=quiet - elif [[ $p == "+V" || $p == "++verbose" ]] ; then + elif [[ ${p} == "+V" || ${p} == "++verbose" ]] ; then verbosity=verbose - elif [[ $p == "+l" || $p == "++light" ]] ; then + elif [[ ${p} == "+l" || ${p} == "++light" ]] ; then do_color=light - elif [[ $p == "+d" || $p == "++dark" ]] ; then + elif [[ ${p} == "+d" || ${p} == "++dark" ]] ; then do_color=dark - elif [[ $p == "+n" || $p == "++no_color" ]] ; then + elif [[ ${p} == "+n" || ${p} == "++no_color" ]] ; then do_color=none fi else - if [[ $grab_next == "defines" ]] ; then - if [[ $defines == "" ]] ; then - defines=$p + if [[ ${grab_next} == "defines" ]] ; then + if [[ ${defines} == "" ]] ; then + defines=${p} else - defines="$defines $p" + defines="${defines} ${p}" fi - elif [[ $grab_next == "modes" ]] ; then - if [[ $modes == "" ]] ; then - modes=$p + elif [[ ${grab_next} == "modes" ]] ; then + if [[ ${modes} == "" ]] ; then + modes=${p} else - modes="$modes $p" + modes="${modes} ${p}" fi - elif [[ $grab_next == "process" ]] ; then - process="$p" - elif [[ $grab_next == "file_settings" ]] ; then - file_settings="$p" - elif [[ $grab_next == "path_build" ]] ; then - path_build=$(process_post_path_fix $p) - elif [[ $grab_next == "path_source_build" ]] ; then - path_source_build=$(process_post_path_fix $p) - elif [[ $grab_next == "path_source_codes" ]] ; then - path_source_codes=$(process_post_path_fix $p) - elif [[ $grab_next == "path_source_common" ]] ; then - path_source_common=$(process_post_path_fix $p) - elif [[ $grab_next == "path_source_data" ]] ; then - path_source_data=$(process_post_path_fix $p) - elif [[ $grab_next == "path_source_documents" ]] ; then - path_source_documents=$(process_post_path_fix $p) - elif [[ $grab_next == "path_source_licenses" ]] ; then - path_source_licenses=$(process_post_path_fix $p) - elif [[ $grab_next == "path_source_settings" ]] ; then - path_source_settings=$(process_post_path_fix $p) - elif [[ $grab_next == "path_work" ]] ; then - path_work=$(process_post_path_fix $p) + elif [[ ${grab_next} == "process" ]] ; then + process="${p}" + elif [[ ${grab_next} == "file_settings" ]] ; then + file_settings="${p}" + elif [[ ${grab_next} == "path_build" ]] ; then + path_build=$(process_post_path_fix ${p}) + elif [[ ${grab_next} == "path_source_build" ]] ; then + path_source_build=$(process_post_path_fix ${p}) + elif [[ ${grab_next} == "path_source_codes" ]] ; then + path_source_codes=$(process_post_path_fix ${p}) + elif [[ ${grab_next} == "path_source_common" ]] ; then + path_source_common=$(process_post_path_fix ${p}) + elif [[ ${grab_next} == "path_source_data" ]] ; then + path_source_data=$(process_post_path_fix ${p}) + elif [[ ${grab_next} == "path_source_documents" ]] ; then + path_source_documents=$(process_post_path_fix ${p}) + elif [[ ${grab_next} == "path_source_licenses" ]] ; then + path_source_licenses=$(process_post_path_fix ${p}) + elif [[ ${grab_next} == "path_source_settings" ]] ; then + path_source_settings=$(process_post_path_fix ${p}) + elif [[ ${grab_next} == "path_work" ]] ; then + path_work=$(process_post_path_fix ${p}) fi grab_next= @@ -167,14 +168,14 @@ process_post_main() { p= fi - if [[ $do_color == "light" ]] ; then + if [[ ${do_color} == "light" ]] ; then c_error="\\033[1;31m" c_warning="\\033[0;31m" c_title="\\033[1;34m" c_highlight="\\033[0;34m" c_notice="\\033[0;01m" c_important="\\033[0;35m" - elif [[ $do_color == "none" ]] ; then + elif [[ ${do_color} == "none" ]] ; then c_reset= c_title= c_error= @@ -186,65 +187,66 @@ process_post_main() { c_prefix= fi - # update paths based on parameters. - path_data_build="${path_data}build$path_directory_separator" - - path_sources_bash="${path_sources}bash$path_directory_separator" - path_sources_c="${path_sources}c$path_directory_separator" - path_sources_cpp="${path_sources}c++$path_directory_separator" - - path_build_documents="${path_build}documents$path_directory_separator" - path_build_includes="${path_build}includes$path_directory_separator" - path_build_libraries="${path_build}libraries$path_directory_separator" - path_build_libraries_script="${path_build_libraries}script$path_directory_separator" - path_build_libraries_shared="${path_build_libraries}shared$path_directory_separator" - path_build_libraries_static="${path_build_libraries}static$path_directory_separator" - path_build_objects="${path_build}objects$path_directory_separator" - path_build_process="${path_build}process$path_directory_separator" - path_build_programs="${path_build}programs$path_directory_separator" - path_build_programs_script="${path_build_programs}script$path_directory_separator" - path_build_programs_shared="${path_build_programs}shared$path_directory_separator" - path_build_programs_static="${path_build_programs}static$path_directory_separator" - path_build_settings="${path_build}settings$path_directory_separator" - - if [[ $path_work != "" ]] ; then - path_work_includes="${path_work}includes$path_directory_separator" - path_work_libraries="${path_work_libraries}libraries$path_directory_separator" - path_work_libraries_script="${path_work_libraries_script}script$path_directory_separator" - path_work_libraries_shared="${path_work_libraries_shared}shared$path_directory_separator" - path_work_libraries_static="${path_work_libraries_static}static$path_directory_separator" - path_work_programs="${path_work_programs}programs$path_directory_separator" - path_work_programs_script="${path_work_programs_script}script$path_directory_separator" - path_work_programs_shared="${path_work_programs_shared}shared$path_directory_separator" - path_work_programs_static="${path_work_programs_static}static$path_directory_separator" + # Update paths based on parameters. + path_data_build="${path_data}build${path_directory_separator}" + + path_sources_bash="${path_sources}bash${path_directory_separator}" + path_sources_c="${path_sources}c${path_directory_separator}" + path_sources_cpp="${path_sources}c++${path_directory_separator}" + + path_build_documents="${path_build}documents${path_directory_separator}" + path_build_includes="${path_build}includes${path_directory_separator}" + path_build_libraries="${path_build}libraries${path_directory_separator}" + path_build_libraries_script="${path_build_libraries}script${path_directory_separator}" + path_build_libraries_shared="${path_build_libraries}shared${path_directory_separator}" + path_build_libraries_static="${path_build_libraries}static${path_directory_separator}" + path_build_objects="${path_build}objects${path_directory_separator}" + path_build_process="${path_build}process${path_directory_separator}" + path_build_programs="${path_build}programs${path_directory_separator}" + path_build_programs_script="${path_build_programs}script${path_directory_separator}" + path_build_programs_shared="${path_build_programs}shared${path_directory_separator}" + path_build_programs_static="${path_build_programs}static${path_directory_separator}" + path_build_settings="${path_build}settings${path_directory_separator}" + + if [[ ${path_work} != "" ]] ; then + path_work_includes="${path_work}includes${path_directory_separator}" + path_work_libraries="${path_work_libraries}libraries${path_directory_separator}" + path_work_libraries_script="${path_work_libraries_script}script${path_directory_separator}" + path_work_libraries_shared="${path_work_libraries_shared}shared${path_directory_separator}" + path_work_libraries_static="${path_work_libraries_static}static${path_directory_separator}" + path_work_programs="${path_work_programs}programs${path_directory_separator}" + path_work_programs_script="${path_work_programs_script}script${path_directory_separator}" + path_work_programs_shared="${path_work_programs_shared}shared${path_directory_separator}" + path_work_programs_static="${path_work_programs_static}static${path_directory_separator}" fi file_data_build_dependencies="${path_data_build}dependencies" file_data_build_settings="${path_data_build}settings" file_documents_readme="${path_documents}readme" - if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then echo - echo -e "${c_title}Completed Operation: $c_reset$c_notice$operation$c_reset" + echo -e "${c_title}Completed Operation: ${c_reset}${c_notice}${operation}${c_reset}" - if [[ $modes != "" ]] ; then - echo -e " Modes: $c_reset$c_notice$modes$c_reset" + if [[ ${modes} != "" ]] ; then + echo -e " Modes: ${c_reset}${c_notice}${modes}${c_reset}" fi - if [[ $defines != "" ]] ; then - echo -e " Defines: $c_reset$c_notice$defines$c_reset" + if [[ ${defines} != "" ]] ; then + echo -e " Defines: ${c_reset}${c_notice}${defines}${c_reset}" fi fi - # cleanup and return. + # Clean up and return. unset process_post_main unset process_post_path_fix + return 0 } process_post_path_fix() { - echo -n $* | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|" + echo -n ${*} | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|" } -# note: "$@" is necessary to preserve quoted arguments when passing to function. -process_post_main "$@" +# Note: "${@}" is necessary to preserve quoted arguments when passing to function. +process_post_main "${@}" diff --git a/level_3/fake/data/build/process_pre.sh b/level_3/fake/data/build/process_pre.sh index 0eb3b56..6d6d1f5 100755 --- a/level_3/fake/data/build/process_pre.sh +++ b/level_3/fake/data/build/process_pre.sh @@ -16,7 +16,7 @@ process_pre_main() { local p= local t=0 - # custom color codes. + # Custom color codes. local c_reset="\\033[0m" local c_title="\\033[1;33m" local c_error="\\033[1;31m" @@ -27,7 +27,7 @@ process_pre_main() { local c_subtle="\\033[1;30m" local c_prefix="\\" - # the supported parameters. + # The supported parameters. local operation= local defines= local modes= @@ -39,7 +39,7 @@ process_pre_main() { local path_work= local verbosity=normal - # generated paths and standard paths. + # Generated paths and standard paths. local path_directory_separator="/" local path_data_build= local path_documents="documents/" @@ -57,12 +57,12 @@ process_pre_main() { local path_work_programs_shared= local path_work_programs_static= - # generated file paths. + # Generated file paths. local file_data_build_dependencies= local file_data_build_settings= local file_documents_readme= - # standard build paths. + # Standard build paths. local path_build_documents= local path_build_includes= local path_build_libraries= @@ -77,87 +77,88 @@ process_pre_main() { local path_build_programs_static= local path_build_settings= - # grab all supported parameters, ignoring duplicates. - if [[ $# -gt 0 ]] ; then - t=$# + # Grab all supported parameters, ignoring duplicates. + if [[ ${#} -gt 0 ]] ; then + t=${#} - while [[ $i -lt $t ]] ; do - let i=$i+1 + while [[ ${i} -lt ${t} ]] ; do + + let i++ p="${!i}" - if [[ $grab_next == "" ]] ; then - if [[ $p == "build" || $p == "clean" || $p == "make" || $p == "skeleton" ]] ; then - if [[ $operation == "" ]] ; then - operation=$p + if [[ ${grab_next} == "" ]] ; then + if [[ ${p} == "build" || ${p} == "clean" || ${p} == "make" || ${p} == "skeleton" ]] ; then + if [[ ${operation} == "" ]] ; then + operation=${p} fi - elif [[ $p == "-d" || $p == "--define" ]] ; then + elif [[ ${p} == "-d" || ${p} == "--define" ]] ; then grab_next="defines" - elif [[ $p == "-m" || $p == "--mode" ]] ; then + elif [[ ${p} == "-m" || ${p} == "--mode" ]] ; then grab_next="modes" - elif [[ $p == "-p" || $p == "--process" ]] ; then + elif [[ ${p} == "-p" || ${p} == "--process" ]] ; then grab_next="process" - elif [[ $p == "-s" || $p == "--settings" ]] ; then + elif [[ ${p} == "-s" || ${p} == "--settings" ]] ; then grab_next="file_settings" - elif [[ $p == "-b" || $p == "--build" ]] ; then + elif [[ ${p} == "-b" || ${p} == "--build" ]] ; then grab_next="path_build" - elif [[ $p == "-D" || $p == "--data" ]] ; then + elif [[ ${p} == "-D" || ${p} == "--data" ]] ; then grab_next="path_data" - elif [[ $p == "-S" || $p == "--sources" ]] ; then + elif [[ ${p} == "-S" || ${p} == "--sources" ]] ; then grab_next="path_sources" - elif [[ $p == "-w" || $p == "--work" ]] ; then + elif [[ ${p} == "-w" || ${p} == "--work" ]] ; then grab_next="path_work" - elif [[ $p == "+D" || $p == "++debug" ]] ; then + elif [[ ${p} == "+D" || ${p} == "++debug" ]] ; then verbosity=debug - elif [[ $p == "+E" || $p == "++error" ]] ; then + elif [[ ${p} == "+E" || ${p} == "++error" ]] ; then verbosity=error - elif [[ $p == "+N" || $p == "++normal" ]] ; then + elif [[ ${p} == "+N" || ${p} == "++normal" ]] ; then verbosity=normal - elif [[ $p == "+Q" || $p == "++quiet" ]] ; then + elif [[ ${p} == "+Q" || ${p} == "++quiet" ]] ; then verbosity=quiet - elif [[ $p == "+V" || $p == "++verbose" ]] ; then + elif [[ ${p} == "+V" || ${p} == "++verbose" ]] ; then verbosity=verbose - elif [[ $p == "+l" || $p == "++light" ]] ; then + elif [[ ${p} == "+l" || ${p} == "++light" ]] ; then do_color=light - elif [[ $p == "+d" || $p == "++dark" ]] ; then + elif [[ ${p} == "+d" || ${p} == "++dark" ]] ; then do_color=dark - elif [[ $p == "+n" || $p == "++no_color" ]] ; then + elif [[ ${p} == "+n" || ${p} == "++no_color" ]] ; then do_color=none fi else - if [[ $grab_next == "defines" ]] ; then - if [[ $defines == "" ]] ; then - defines=$p + if [[ ${grab_next} == "defines" ]] ; then + if [[ ${defines} == "" ]] ; then + defines=${p} else - defines="$defines $p" + defines="${defines} ${p}" fi - elif [[ $grab_next == "modes" ]] ; then - if [[ $modes == "" ]] ; then - modes=$p + elif [[ ${grab_next} == "modes" ]] ; then + if [[ ${modes} == "" ]] ; then + modes=${p} else - modes="$modes $p" + modes="${modes} ${p}" fi - elif [[ $grab_next == "process" ]] ; then - process="$p" - elif [[ $grab_next == "file_settings" ]] ; then - file_settings="$p" - elif [[ $grab_next == "path_build" ]] ; then - path_build=$(process_pre_path_fix $p) - elif [[ $grab_next == "path_source_build" ]] ; then - path_source_build=$(process_pre_path_fix $p) - elif [[ $grab_next == "path_source_codes" ]] ; then - path_source_codes=$(process_pre_path_fix $p) - elif [[ $grab_next == "path_source_common" ]] ; then - path_source_common=$(process_pre_path_fix $p) - elif [[ $grab_next == "path_source_data" ]] ; then - path_source_data=$(process_pre_path_fix $p) - elif [[ $grab_next == "path_source_documents" ]] ; then - path_source_documents=$(process_pre_path_fix $p) - elif [[ $grab_next == "path_source_licenses" ]] ; then - path_source_licenses=$(process_pre_path_fix $p) - elif [[ $grab_next == "path_source_settings" ]] ; then - path_source_settings=$(process_pre_path_fix $p) - elif [[ $grab_next == "path_work" ]] ; then - path_work=$(process_pre_path_fix $p) + elif [[ ${grab_next} == "process" ]] ; then + process="${p}" + elif [[ ${grab_next} == "file_settings" ]] ; then + file_settings="${p}" + elif [[ ${grab_next} == "path_build" ]] ; then + path_build=$(process_pre_path_fix ${p}) + elif [[ ${grab_next} == "path_source_build" ]] ; then + path_source_build=$(process_pre_path_fix ${p}) + elif [[ ${grab_next} == "path_source_codes" ]] ; then + path_source_codes=$(process_pre_path_fix ${p}) + elif [[ ${grab_next} == "path_source_common" ]] ; then + path_source_common=$(process_pre_path_fix ${p}) + elif [[ ${grab_next} == "path_source_data" ]] ; then + path_source_data=$(process_pre_path_fix ${p}) + elif [[ ${grab_next} == "path_source_documents" ]] ; then + path_source_documents=$(process_pre_path_fix ${p}) + elif [[ ${grab_next} == "path_source_licenses" ]] ; then + path_source_licenses=$(process_pre_path_fix ${p}) + elif [[ ${grab_next} == "path_source_settings" ]] ; then + path_source_settings=$(process_pre_path_fix ${p}) + elif [[ ${grab_next} == "path_work" ]] ; then + path_work=$(process_pre_path_fix ${p}) fi grab_next= @@ -167,14 +168,14 @@ process_pre_main() { p= fi - if [[ $do_color == "light" ]] ; then + if [[ ${do_color} == "light" ]] ; then c_error="\\033[1;31m" c_warning="\\033[0;31m" c_title="\\033[1;34m" c_highlight="\\033[0;34m" c_notice="\\033[0;01m" c_important="\\033[0;35m" - elif [[ $do_color == "none" ]] ; then + elif [[ ${do_color} == "none" ]] ; then c_reset= c_title= c_error= @@ -187,64 +188,65 @@ process_pre_main() { fi # update paths based on parameters. - path_data_build="${path_data}build$path_directory_separator" - - path_sources_bash="${path_sources}bash$path_directory_separator" - path_sources_c="${path_sources}c$path_directory_separator" - path_sources_cpp="${path_sources}c++$path_directory_separator" - - path_build_documents="${path_build}documents$path_directory_separator" - path_build_includes="${path_build}includes$path_directory_separator" - path_build_libraries="${path_build}libraries$path_directory_separator" - path_build_libraries_script="${path_build_libraries}script$path_directory_separator" - path_build_libraries_shared="${path_build_libraries}shared$path_directory_separator" - path_build_libraries_static="${path_build_libraries}static$path_directory_separator" - path_build_objects="${path_build}objects$path_directory_separator" - path_build_process="${path_build}process$path_directory_separator" - path_build_programs="${path_build}programs$path_directory_separator" - path_build_programs_script="${path_build_programs}script$path_directory_separator" - path_build_programs_shared="${path_build_programs}shared$path_directory_separator" - path_build_programs_static="${path_build_programs}static$path_directory_separator" - path_build_settings="${path_build}settings$path_directory_separator" - - if [[ $path_work != "" ]] ; then - path_work_includes="${path_work}includes$path_directory_separator" - path_work_libraries="${path_work_libraries}libraries$path_directory_separator" - path_work_libraries_script="${path_work_libraries_script}script$path_directory_separator" - path_work_libraries_shared="${path_work_libraries_shared}shared$path_directory_separator" - path_work_libraries_static="${path_work_libraries_static}static$path_directory_separator" - path_work_programs="${path_work_programs}programs$path_directory_separator" - path_work_programs_script="${path_work_programs_script}script$path_directory_separator" - path_work_programs_shared="${path_work_programs_shared}shared$path_directory_separator" - path_work_programs_static="${path_work_programs_static}static$path_directory_separator" + path_data_build="${path_data}build${path_directory_separator}" + + path_sources_bash="${path_sources}bash${path_directory_separator}" + path_sources_c="${path_sources}c${path_directory_separator}" + path_sources_cpp="${path_sources}c++${path_directory_separator}" + + path_build_documents="${path_build}documents${path_directory_separator}" + path_build_includes="${path_build}includes${path_directory_separator}" + path_build_libraries="${path_build}libraries${path_directory_separator}" + path_build_libraries_script="${path_build_libraries}script${path_directory_separator}" + path_build_libraries_shared="${path_build_libraries}shared${path_directory_separator}" + path_build_libraries_static="${path_build_libraries}static${path_directory_separator}" + path_build_objects="${path_build}objects${path_directory_separator}" + path_build_process="${path_build}process${path_directory_separator}" + path_build_programs="${path_build}programs${path_directory_separator}" + path_build_programs_script="${path_build_programs}script${path_directory_separator}" + path_build_programs_shared="${path_build_programs}shared${path_directory_separator}" + path_build_programs_static="${path_build_programs}static${path_directory_separator}" + path_build_settings="${path_build}settings${path_directory_separator}" + + if [[ ${path_work} != "" ]] ; then + path_work_includes="${path_work}includes${path_directory_separator}" + path_work_libraries="${path_work_libraries}libraries${path_directory_separator}" + path_work_libraries_script="${path_work_libraries_script}script${path_directory_separator}" + path_work_libraries_shared="${path_work_libraries_shared}shared${path_directory_separator}" + path_work_libraries_static="${path_work_libraries_static}static${path_directory_separator}" + path_work_programs="${path_work_programs}programs${path_directory_separator}" + path_work_programs_script="${path_work_programs_script}script${path_directory_separator}" + path_work_programs_shared="${path_work_programs_shared}shared${path_directory_separator}" + path_work_programs_static="${path_work_programs_static}static${path_directory_separator}" fi file_data_build_dependencies="${path_data_build}dependencies" file_data_build_settings="${path_data_build}settings" file_documents_readme="${path_documents}readme" - if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then echo - echo -e "${c_title}Processing Operation: $c_reset$c_notice$operation$c_reset" + echo -e "${c_title}Processing Operation: ${c_reset}${c_notice}${operation}${c_reset}" - if [[ $modes != "" ]] ; then - echo -e " Modes: $c_reset$c_notice$modes$c_reset" + if [[ ${modes} != "" ]] ; then + echo -e " Modes: ${c_reset}${c_notice}${modes}${c_reset}" fi - if [[ $defines != "" ]] ; then - echo -e " Defines: $c_reset$c_notice$defines$c_reset" + if [[ ${defines} != "" ]] ; then + echo -e " Defines: ${c_reset}${c_notice}${defines}${c_reset}" fi fi - # cleanup and return. + # Clean up and return. unset process_pre_main unset process_pre_path_fix + return 0 } process_pre_path_fix() { - echo -n $* | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|" + echo -n ${*} | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|" } -# note: "$@" is necessary to preserve quoted arguments when passing to function. -process_pre_main "$@" +# Note: "${@}" is necessary to preserve quoted arguments when passing to function. +process_pre_main "${@}" diff --git a/level_3/fake/data/projects/go/example_go/data/build/process_post.sh b/level_3/fake/data/projects/go/example_go/data/build/process_post.sh index a5fc4d8..b9b5460 100755 --- a/level_3/fake/data/projects/go/example_go/data/build/process_post.sh +++ b/level_3/fake/data/projects/go/example_go/data/build/process_post.sh @@ -3,6 +3,7 @@ main() { local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope. + unset main } main ${*} diff --git a/level_3/fake/data/projects/go/example_go/data/build/process_pre.sh b/level_3/fake/data/projects/go/example_go/data/build/process_pre.sh index a5fc4d8..b9b5460 100755 --- a/level_3/fake/data/projects/go/example_go/data/build/process_pre.sh +++ b/level_3/fake/data/projects/go/example_go/data/build/process_pre.sh @@ -3,6 +3,7 @@ main() { local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope. + unset main } main ${*}