From: Kevin Day Date: Sat, 28 Jun 2025 03:35:45 +0000 (-0500) Subject: Cleanup: Apply new script practices. X-Git-Tag: 0.7.2~3 X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=f856496d258a223eb7eb5f8fe645297e8af27b46;p=fll Cleanup: Apply new script practices. 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`. --- diff --git a/build/scripts/bootstrap-example.sh b/build/scripts/bootstrap-example.sh index c049419..f45f5fb 100644 --- a/build/scripts/bootstrap-example.sh +++ b/build/scripts/bootstrap-example.sh @@ -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 @@ -329,7 +329,7 @@ boostrap_process() { fi done - if [[ $skip != "" ]] ; then + if [[ ${skip} != "" ]] ; then echo "Skipping program: '${i}'." echo diff --git a/build/scripts/bootstrap.sh b/build/scripts/bootstrap.sh index 1e5562c..dfb8b04 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 23467c9..87b274a 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 fb971b5..59f4119 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 fe89988..ea4b0ec 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.7.2 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 51ddbb0..f277843 100644 --- a/build/scripts/test.sh +++ b/build/scripts/test.sh @@ -76,8 +76,8 @@ test_main() { local projects_no_tests="f_type" local programs="fss_read" - if [[ $# -gt 0 ]] ; then - t=$# + if [[ ${#} -gt 0 ]] ; then + t=${#} while [[ ${i} -lt ${t} ]] ; do @@ -155,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/ @@ -289,7 +289,7 @@ test_main() { if [[ ${failure} -eq 0 ]] ; then test_operate - let failure=$? + let failure=${?} fi test_cleanup @@ -1010,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 58866ad..20ebe09 100755 --- a/level_3/fake/data/build/process_post.sh +++ b/level_3/fake/data/build/process_post.sh @@ -248,5 +248,5 @@ 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}|" } -# 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 469af56..540997b 100755 --- a/level_3/fake/data/build/process_pre.sh +++ b/level_3/fake/data/build/process_pre.sh @@ -248,5 +248,5 @@ 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}|" } -# 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/fss_read/tests/runtime/script/generate.sh b/level_3/fss_read/tests/runtime/script/generate.sh index d3543bb..5d74c47 100644 --- a/level_3/fss_read/tests/runtime/script/generate.sh +++ b/level_3/fss_read/tests/runtime/script/generate.sh @@ -21,28 +21,28 @@ generate_main() { local test_current= local test_set="${1}" - standard=$(echo -n ${test_set} | sed -e 's|^.*-||g') + standard=$(sed -e 's|^.*-||g' <<< ${test_set}) - if [[ $standard == "" ]] ; then + if [[ ${standard} == "" ]] ; then echo "ERROR: No standard specified." return 1 fi - if [[ $file_source == "" ]] ; then + if [[ ${file_source} == "" ]] ; then echo "ERROR: No source file specified." return 1 fi - if [[ $path_destination == "" ]] ; then + if [[ ${path_destination} == "" ]] ; then echo "ERROR: No destination path specified." return 1 fi - file_source=$(echo ${file_source} | sed -e 's|^//*|/|' -e 's|//*|/|' -e 's|/*$||') - path_destination=$(echo ${path_destination} | sed -e 's|^//*|/|' -e 's|/*$|/|') + file_source=$(sed -e 's|^//*|/|' -e 's|//*|/|' -e 's|/*$||' <<< ${file_source}) + path_destination=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${path_destination}) if [[ ! -f ${file_source} ]] ; then echo "ERROR: The source file '${file_source}' either does not exist or is not a file." @@ -56,7 +56,7 @@ generate_main() { return 1 fi - test_base=$(echo ${file_source} | sed -e 's|.*/||g' -e 's|\..*$||') + test_base=$(sed -e 's|.*/||g' -e 's|\..*$||' <<< ${file_source}) test_current="${path_destination}${test_base}-" if [[ ${test_set} == "0000" ]] ; then @@ -360,7 +360,7 @@ generate_operate_0000() { echo "Generation Complete" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 echo @@ -368,7 +368,7 @@ generate_operate_0000() { echo fi - return $failure + return ${failure} } generate_operate_0001() { @@ -639,7 +639,7 @@ generate_operate_0001() { echo "Generation Complete" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 echo @@ -647,7 +647,7 @@ generate_operate_0001() { echo fi - return $failure + return ${failure} } generate_operate_0002() { @@ -918,7 +918,7 @@ generate_operate_0002() { echo "Generation Complete" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 echo @@ -926,7 +926,7 @@ generate_operate_0002() { echo fi - return $failure + return ${failure} } generate_operate_0003() { @@ -1197,7 +1197,7 @@ generate_operate_0003() { echo "Generation Complete" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 echo @@ -1205,7 +1205,7 @@ generate_operate_0003() { echo fi - return $failure + return ${failure} } generate_operate_0008() { @@ -1478,7 +1478,7 @@ generate_operate_0008() { echo "Generation Complete" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 echo @@ -1486,7 +1486,7 @@ generate_operate_0008() { echo fi - return $failure + return ${failure} } generate_operate_0008_special_cases() { @@ -1852,7 +1852,7 @@ generate_operate_0008_special_cases() { generate_operate_run_0008 +n -oc -l 1 -d 1 -n depth_1_set_3_same_name -a 2 -d 3 -a 0 ${file_source} > ${test_current}object_content-line_1-depth_1-name_depth_1_set_3_same_name-at_2-depth_3-at_0.expect && generate_operate_run_0008 +n -oc -l 1 -d 2 -n depth_2_same_across_sets -a 2 -d 3 ${file_source} > ${test_current}object_content-line_1-depth_2-name_depth_2_same_across_sets-at_2-depth_3.expect - if [[ $? -ne 0 ]] ; then return 1; fi + if [[ ${?} -ne 0 ]] ; then return 1; fi fi return 0 @@ -2126,7 +2126,7 @@ generate_operate_000e() { echo "Generation Complete" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 echo @@ -2134,63 +2134,63 @@ generate_operate_000e() { echo fi - return $failure + return ${failure} } generate_operate_run() { - last_command="fss_read ${@}" + last_command="fss_read \"${@}\"" - fss_read "$@" + fss_read "${@}" - return $? + return ${?} } generate_operate_run_0000() { - last_command="fss_basic_read ${@}" + last_command="fss_basic_read \"${@}\"" - fss_basic_read "$@" + fss_basic_read "${@}" - return $? + return ${?} } generate_operate_run_0001() { - last_command="fss_extended_read ${@}" + last_command="fss_extended_read \"${@}\"" - fss_extended_read "$@" + fss_extended_read "${@}" - return $? + return ${?} } generate_operate_run_0002() { - last_command="fss_basic_list_read ${@}" + last_command="fss_basic_list_read \"${@}\"" - fss_basic_list_read "$@" + fss_basic_list_read "${@}" - return $? + return ${?} } generate_operate_run_0003() { - last_command="fss_extended_list_read ${@}" + last_command="fss_extended_list_read \"${@}\"" - fss_extended_list_read "$@" + fss_extended_list_read "${@}" - return $? + return ${?} } generate_operate_run_0008() { - last_command="fss_embedded_list_read ${@}" + last_command="fss_embedded_list_read \"${@}\"" - fss_embedded_list_read "$@" + fss_embedded_list_read "${@}" - return $? + return ${?} } generate_operate_run_000e() { - last_command="fss_payload_read ${@}" + last_command="fss_payload_read \"${@}\"" - fss_payload_read "$@" + fss_payload_read "${@}" - return $? + return ${?} } generate_operate_test_standard() { @@ -2465,7 +2465,7 @@ generate_operate_test_standard() { echo "Generation Complete" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 echo @@ -2473,7 +2473,7 @@ generate_operate_test_standard() { echo fi - return $failure + return ${failure} } generate_operate_test_standard_special_cases() { @@ -2481,11 +2481,11 @@ generate_operate_test_standard_special_cases() { if [[ ${standard} == "0008" ]] ; then generate_operate_test_standard_special_cases_0008 - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 fi - return $failure + return ${failure} fi return 0 @@ -2854,11 +2854,11 @@ generate_operate_test_standard_special_cases_0008() { generate_operate_run_0008 +n -oc -l 1 -d 1 -n depth_1_set_3_same_name -a 2 -d 3 -a 0 ${file_source} > ${test_current}object_content-line_1-depth_1-name_depth_1_set_3_same_name-at_2-depth_3-at_0.expect && generate_operate_run_0008 +n -oc -l 1 -d 2 -n depth_2_same_across_sets -a 2 -d 3 ${file_source} > ${test_current}object_content-line_1-depth_2-name_depth_2_same_across_sets-at_2-depth_3.expect - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 fi - return $failure + return ${failure} fi return 0 @@ -2887,4 +2887,4 @@ generate_cleanup() { unset generate_cleanup } -generate_main "$@" +generate_main "${@}" diff --git a/level_3/fss_read/tests/runtime/script/verify.sh b/level_3/fss_read/tests/runtime/script/verify.sh index b6eb78c..c167328 100644 --- a/level_3/fss_read/tests/runtime/script/verify.sh +++ b/level_3/fss_read/tests/runtime/script/verify.sh @@ -20,20 +20,20 @@ verify_main() { local hash_build= local hash_expect= - if [[ $path_build == "" ]] ; then + if [[ ${path_build} == "" ]] ; then echo "ERROR: No build path specified." return 1 fi - if [[ $path_expect == "" ]] ; then + if [[ ${path_expect} == "" ]] ; then echo "ERROR: No expect path specified." return 1 fi - path_build=$(echo ${path_build} | sed -e 's|^//*|/|' -e 's|/*$|/|') - path_expect=$(echo ${path_expect} | sed -e 's|^//*|/|' -e 's|/*$|/|') + path_build=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${path_build}) + path_expect=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${path_expect}) if [[ ! -d ${path_build} ]] ; then echo "ERROR: The build path '${path_build}' either does not exist or is not a directory." @@ -47,7 +47,7 @@ verify_main() { return 1 fi - if [[ $test_name != "" ]] ; then + if [[ ${test_name} != "" ]] ; then test_name=" for ${test_name}" fi @@ -70,7 +70,7 @@ verify_operate_test_standard() { basename_file=$(basename ${i}) - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then echo "ERROR: basename ${i} failed." let failure=1 @@ -80,7 +80,7 @@ verify_operate_test_standard() { hash_build=$(md5sum ${path_build}${basename_file} | sed -e 's| .*$||') - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then echo "ERROR: md5sum ${path_build}${basename_file} | sed -e 's| .*$||' failed." let failure=1 @@ -90,7 +90,7 @@ verify_operate_test_standard() { hash_expect=$(md5sum ${path_expect}${basename_file} | sed -e 's| .*$||') - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then echo "ERROR: md5sum ${path_expect}${basename_file} | sed -e 's| .*$||' failed." let failure=1 @@ -98,9 +98,9 @@ verify_operate_test_standard() { break fi - basename_file=$(echo -n ${basename_file} | sed -e 's|\.expect$||') + basename_file=$(sed -e 's|\.expect$||' <<< ${basename_file}) - if [[ $hash_build == $hash_expect ]] ; then + if [[ ${hash_build} == ${hash_expect} ]] ; then echo "[ Success ] ${basename_file}." let success++ @@ -113,19 +113,19 @@ verify_operate_test_standard() { done - if [[ $fail -gt 0 || $success -gt 0 ]] ; then - message=" (Success: $success, Fail: $fail)" + if [[ ${fail} -gt 0 || ${success} -gt 0 ]] ; then + message=" (Success: ${success}, Fail: ${fail})" fi echo - if [[ $failure -eq 1 ]] ; then + if [[ ${failure} -eq 1 ]] ; then echo "Failure! Some or all tests failed${message}${test_name}." else echo "Success! All tests passed${message}${test_name}." fi - return $failure + return ${failure} } verify_cleanup() { @@ -135,4 +135,4 @@ verify_cleanup() { unset verify_cleanup } -verify_main "$@" +verify_main "${@}" diff --git a/level_3/iki_read/tests/runtime/script/generate.sh b/level_3/iki_read/tests/runtime/script/generate.sh index 40dcc5d..9aa1c33 100644 --- a/level_3/iki_read/tests/runtime/script/generate.sh +++ b/level_3/iki_read/tests/runtime/script/generate.sh @@ -22,28 +22,28 @@ generate_main() { local test_set="${1}" local test_command= - standard=$(echo -n ${test_set} | sed -e 's|^.*-||g') + standard=$(sed -e 's|^.*-||g' <<< ${test_set}) - if [[ $standard == "" ]] ; then + if [[ ${standard} == "" ]] ; then echo "ERROR: No standard specified." return 1 fi - if [[ $file_source == "" ]] ; then + if [[ ${file_source} == "" ]] ; then echo "ERROR: No source file specified." return 1 fi - if [[ $path_destination == "" ]] ; then + if [[ ${path_destination} == "" ]] ; then echo "ERROR: No destination path specified." return 1 fi - file_source=$(echo ${file_source} | sed -e 's|^//*|/|' -e 's|//*|/|' -e 's|/*$||') - path_destination=$(echo ${path_destination} | sed -e 's|^//*|/|' -e 's|/*$|/|') + file_source=$(sed -e 's|^//*|/|' -e 's|//*|/|' -e 's|/*$||' <<< ${file_source}) + path_destination=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${path_destination}) if [[ ! -f ${file_source} ]] ; then echo "ERROR: The source file '${file_source}' either does not exist or is not a file." @@ -57,7 +57,7 @@ generate_main() { return 1 fi - test_base=$(echo ${file_source} | sed -e 's|.*/||g' -e 's|\..*$||') + test_base=$(sed -e 's|.*/||g' -e 's|\..*$||' <<< ${file_source}) test_current="${path_destination}${test_base}-" if [[ ${test_set} == "iki" || ${test_set} == "test-iki" ]] ; then @@ -2651,7 +2651,7 @@ generate_operate_iki() { echo "Generation Complete" - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then let failure=1 echo @@ -2659,7 +2659,7 @@ generate_operate_iki() { echo fi - return $failure + return ${failure} } generate_operate_run() { @@ -2667,14 +2667,14 @@ generate_operate_run() { if [[ ${test_command} == "eki" ]] ; then last_command="eki_read ${@}" - eki_read "$@" + eki_read "${@}" else last_command="iki_read ${@}" - iki_read "$@" + iki_read "${@}" fi - return $? + return ${?} } generate_cleanup() { @@ -2685,4 +2685,4 @@ generate_cleanup() { unset generate_cleanup } -generate_main "$@" +generate_main "${@}" diff --git a/level_3/iki_read/tests/runtime/script/verify.sh b/level_3/iki_read/tests/runtime/script/verify.sh index b6eb78c..c167328 100644 --- a/level_3/iki_read/tests/runtime/script/verify.sh +++ b/level_3/iki_read/tests/runtime/script/verify.sh @@ -20,20 +20,20 @@ verify_main() { local hash_build= local hash_expect= - if [[ $path_build == "" ]] ; then + if [[ ${path_build} == "" ]] ; then echo "ERROR: No build path specified." return 1 fi - if [[ $path_expect == "" ]] ; then + if [[ ${path_expect} == "" ]] ; then echo "ERROR: No expect path specified." return 1 fi - path_build=$(echo ${path_build} | sed -e 's|^//*|/|' -e 's|/*$|/|') - path_expect=$(echo ${path_expect} | sed -e 's|^//*|/|' -e 's|/*$|/|') + path_build=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${path_build}) + path_expect=$(sed -e 's|^//*|/|' -e 's|/*$|/|' <<< ${path_expect}) if [[ ! -d ${path_build} ]] ; then echo "ERROR: The build path '${path_build}' either does not exist or is not a directory." @@ -47,7 +47,7 @@ verify_main() { return 1 fi - if [[ $test_name != "" ]] ; then + if [[ ${test_name} != "" ]] ; then test_name=" for ${test_name}" fi @@ -70,7 +70,7 @@ verify_operate_test_standard() { basename_file=$(basename ${i}) - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then echo "ERROR: basename ${i} failed." let failure=1 @@ -80,7 +80,7 @@ verify_operate_test_standard() { hash_build=$(md5sum ${path_build}${basename_file} | sed -e 's| .*$||') - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then echo "ERROR: md5sum ${path_build}${basename_file} | sed -e 's| .*$||' failed." let failure=1 @@ -90,7 +90,7 @@ verify_operate_test_standard() { hash_expect=$(md5sum ${path_expect}${basename_file} | sed -e 's| .*$||') - if [[ $? -ne 0 ]] ; then + if [[ ${?} -ne 0 ]] ; then echo "ERROR: md5sum ${path_expect}${basename_file} | sed -e 's| .*$||' failed." let failure=1 @@ -98,9 +98,9 @@ verify_operate_test_standard() { break fi - basename_file=$(echo -n ${basename_file} | sed -e 's|\.expect$||') + basename_file=$(sed -e 's|\.expect$||' <<< ${basename_file}) - if [[ $hash_build == $hash_expect ]] ; then + if [[ ${hash_build} == ${hash_expect} ]] ; then echo "[ Success ] ${basename_file}." let success++ @@ -113,19 +113,19 @@ verify_operate_test_standard() { done - if [[ $fail -gt 0 || $success -gt 0 ]] ; then - message=" (Success: $success, Fail: $fail)" + if [[ ${fail} -gt 0 || ${success} -gt 0 ]] ; then + message=" (Success: ${success}, Fail: ${fail})" fi echo - if [[ $failure -eq 1 ]] ; then + if [[ ${failure} -eq 1 ]] ; then echo "Failure! Some or all tests failed${message}${test_name}." else echo "Success! All tests passed${message}${test_name}." fi - return $failure + return ${failure} } verify_cleanup() { @@ -135,4 +135,4 @@ verify_cleanup() { unset verify_cleanup } -verify_main "$@" +verify_main "${@}"