# 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() {
j=
p=
- while [[ ${i} -le $# ]] ; do
+ while [[ ${i} -le ${#} ]] ; do
if [[ ${SHELL_ENGINE} == "zsh" ]] ; then
p=${(P)i}
elif [[ ${p} == "-w" || ${p} == "--work" ]] ; then
let i++
- if [[ ${i} -le $# ]] ; then
+ if [[ ${i} -le ${#} ]] ; then
path_work=${p}
fi
fi
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
fi
done
- if [[ $skip != "" ]] ; then
+ if [[ ${skip} != "" ]] ; then
echo "Skipping program: '${i}'."
echo
if [[ ${?} -ne 0 ]] ; then return 1 ; fi
fi
done
- fi
+ fi
done
else
echo
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
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
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}"
# 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
# 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
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=
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=
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=
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=
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=
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=
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=
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=
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}
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}
fi
if [[ ${path_headers} != "" ]] ; then
- path_headers=$(echo ${path_headers} | sed -e 's|/*$|/|')
+ path_headers=$(sed -e 's|/*$|/|' <<< ${path_headers})
fi
}
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"
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"
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"
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
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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
}
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
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
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
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
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
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
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
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
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}"
local verbose=
local verbose_common=
- if [[ $# -gt 0 ]] ; then
- t=$#
+ if [[ ${#} -gt 0 ]] ; then
+ t=${#}
while [[ ${i} -lt ${t} ]] ; do
let i=${i}+1
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=
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}"
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
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
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=
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=
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=
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}"
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
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=
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
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
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
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
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
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
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
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
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
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
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
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=
local verbose_common=
local result=
- if [[ $# -gt 0 ]] ; then
- t=$#
+ if [[ ${#} -gt 0 ]] ; then
+ t=${#}
while [[ ${i} -lt ${t} ]] ; do
let i=${i}+1
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
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|[\!~\`@#$%^&*();:><?/"\\]||g' -e 's@|@@g' -e "s|'||g" -e "s|\s*||g")
+ prepend=$(sed -e 's|[\!~\`@#$%^&*( <<< ${p});:><?/"\\]||g' -e 's@|@@g' -e "s|'||g" -e "s|\s*||g")
fi
grab_next=
for i in build/stand_alone/*.settings ; do
- mode_stand_alone="${mode_stand_alone}$(echo ${i} | sed -e 's|build/stand_alone/||' -e 's|\.settings$||') "
+ mode_stand_alone="${mode_stand_alone}$(sed -e 's|build/stand_alone/||' -e 's|\.settings$||' <<< ${i}) "
done
fi
fi
package_handle_colors() {
- 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=
for directory in ${path_sources}level_0/* ${path_sources}level_1/* ${path_sources}level_2/* ${path_sources}level_3/* ; do
- name="$(echo ${directory} | sed -e "s|${path_sources}level_0/||" -e "s|${path_sources}level_1/||" -e "s|${path_sources}level_2/||" -e "s|${path_sources}level_3/||")"
+ name="$(sed -e "s|${path_sources}level_0/||" -e "s|${path_sources}level_1/||" -e "s|${path_sources}level_2/||" -e "s|${path_sources}level_3/||" <<< ${directory})"
- level_current="$(echo ${directory} | grep -o '\<level_[[:digit:]]/' | sed -e 's|level_||' -e 's|/$||')"
+ level_current="$(grep -sho '\<level_[[:digit:]]/' | sed -e 's|level_||' -e 's|/$||' <<< ${directory})"
if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then
echo
fi
# Additional dependency files are only supported in level_3.
- if [[ $(echo "${directory}" | grep -o "^${path_sources}level_3/") != "" ]] ; then
+ if [[ $(grep -sho "^${path_sources}level_3/" <<< ${directory}) != "" ]] ; then
dependency_files="yes"
# When the files don't exist bash treats the pattern as a literal file.
if [[ ! -f ${dependency_file} ]] ; then
- if [[ $dependency_files == "yes" && "${directory}/data/build/dependencies" != ${dependency_file} ]] ; then
+ if [[ ${dependency_files} == "yes" && "${directory}/data/build/dependencies" != ${dependency_file} ]] ; then
if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then
echo -e "${c_warning}WARNING: The dependency file ${c_notice}${dependency_file}${c_warning} is not found.${c_reset}"
fi
- elif [[ $dependency_files == "no" && "${directory}/data/build/dependencies.*" != ${dependency_file} ]] ; then
+ elif [[ ${dependency_files} == "no" && "${directory}/data/build/dependencies.*" != ${dependency_file} ]] ; then
if [[ ${verbosity} != "quiet" ]] ; then
echo -e "${c_error}ERROR: Cannot build dependencies, failed to find ${c_notice}${dependency_file}${c_error} file(s).${c_reset}"
fi
if [[ ${dependency_file} == "${directory}/data/build/dependencies" ]] ; then
dependency_suffix=
else
- dependency_suffix=$(echo ${dependency_file} | sed -e "s|^${directory}/data/build/dependencies||")
+ dependency_suffix=$(sed -e "s|^${directory}/data/build/dependencies||" <<< ${dependency_file})
fi
if [[ ! -f ${directory}/data/build/settings${dependency_suffix} ]] ; then
dependencies=$(cat ${dependency_file} | sed -e "/^\s*#/d" -e "s|#\.*$||")
- if [[ $(echo "$dependencies" | grep -o "\<f_thread\>") != "" ]] ; then
+ if [[ $(grep -sho "\<f_thread\>" <<< ${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
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
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
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}"
}
package_dependencies_individual_append() {
- local level="$1"
- local dependency="$2"
+ local level="${1}"
+ local dependency="${2}"
local settings=
local libraries=
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
}
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=
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
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
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}"
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}"
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
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
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
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
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
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
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
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
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
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
# 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
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
test_main() {
local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
-
local shell_command=bash
if [[ ${SHELL_ENGINE} == "zsh" ]] ; then
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
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/
if [[ ${failure} -eq 0 ]] ; then
test_operate
- let failure=$?
+ let failure=${?}
fi
test_cleanup
fi
if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then
+ echo
echo -e "Installing ${mode} project '${c_notice}${project}${c_reset}'."
echo
fi
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
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
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
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"
local c_subtle="\\033[1;30m"
local c_prefix="\\"
- # the supported parameters.
+ # The supported parameters.
local operation=
local defines=
local modes=
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/"
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=
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=
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=
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 "${@}"
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"
local c_subtle="\\033[1;30m"
local c_prefix="\\"
- # the supported parameters.
+ # The supported parameters.
local operation=
local defines=
local modes=
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/"
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=
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=
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=
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 "${@}"
main() {
local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+ unset main
}
main ${*}
main() {
local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+ unset main
}
main ${*}