diff options
Diffstat (limited to 'libs')
-rwxr-xr-x | libs/common | 205 | ||||
-rwxr-xr-x | libs/git | 10 | ||||
-rwxr-xr-x | libs/project | 102 | ||||
-rwxr-xr-x | libs/tool | 36 |
4 files changed, 179 insertions, 174 deletions
diff --git a/libs/common b/libs/common index 8f1379ee..ce0df299 100755 --- a/libs/common +++ b/libs/common @@ -35,6 +35,7 @@ BLOBS_IGNORE="blobs-ignore" BLOBS_DISCOVER="blobs-discover" DOTEPOCH=".epoch" +DOTRNDSEED=".rndseed" DOTVERSION=".version" DOTREVISION=".revision" DOTTARFILES=".tarfiles" @@ -59,7 +60,7 @@ arguments_list() { for argument in "$@" do - echo "$argument" + printf '%s\n' "$argument" done } @@ -84,7 +85,7 @@ path_wildcard_expand() { local path=$@ # Evaluation fails with unescaped whitespaces. - path=$( echo "$path" | sed "s/ /\\\ /g" ) + path=$( printf '%s\n' "$path" | sed "s/ /\\\ /g" ) eval "arguments_list "$path"" } @@ -111,7 +112,7 @@ file_checksum_check() { if ! [ -f "$checksum_path" ] then - printf "Could not verify file checksum!\n" >&2 + printf '%s\n' 'Could not verify file checksum!' >&2 return 1 fi @@ -141,7 +142,7 @@ file_signature_check() { if ! [ -f "$signature_path" ] then - printf "Could not verify file signature!\n" >&2 + printf '%s\n' 'Could not verify file signature!' >&2 return 1 fi @@ -180,145 +181,149 @@ directory_filled_check() { } archive_files_create() { - local source_path=$1 - - local directory=$( basename "$source_path" ) - local tarfiles_path="$source_path/$DOTTARFILES" - local revision_path="$source_path/$DOTREVISION" - local version_path="$source_path/$DOTVERSION" - - if git_check "$source_path" - then - git_files "$source_path" | tr -d '\0' > "$tarfiles_path" - echo "$DOTTARFILES" | tr -d '\0' >> "$tarfiles_path" + local source_path="$1" + + local directory="$(basename "${source_path}")" + local tarfiles_path="${source_path}/${DOTTARFILES}" + local revision_path="${source_path}/${DOTREVISION}" + local version_path="${source_path}/${DOTVERSION}" + local epoch_path="${source_path}/${DOTEPOCH}" + local rnd_seed_path="${source_path}/${DOTRNDSEED}" + + # Files in "${tarfiles_path}" are NUL terminated. + # `tr '\0' '\n'` for human-readable output. + if git_check "${source_path}"; then + git_files "${source_path}" > "${tarfiles_path}" + printf '%s\0' "${DOTTARFILES}" >> "${tarfiles_path}" else - touch "$tarfiles_path" - - ( - cd "$source_path" - find - ) | LC_ALL=C sort | sed "s,^./,," | grep -vP "^\.$" > "$tarfiles_path" - fi - - if [ -f "$revision_path" ] - then - echo "$DOTREVISION" | tr -d '\0' >> "$tarfiles_path" - fi - - if [ -f "$version_path" ] - then - echo "$DOTVERSION" | tr -d '\0' >> "$tarfiles_path" + find "${source_path}" -print0 | env LC_ALL='C.UTF-8' sort -z | sed -z "1d;s,^${source_path}/\\?,,;/^${DOTTARFILES}\$/d" > "${tarfiles_path}" fi - if [ -f "$epoch_path" ] - then - echo "$DOTEPOCH" | tr -d '\0' >> "$tarfiles_path" - fi + for dotfile in "${revision_path}" \ + "${version_path}" \ + "${epoch_path}" \ + "${rnd_seed_path}" + do + if [[ -f "${dotfile}" ]]; then + printf '%s\0' ".${dotfile##*.}" >> "${tarfiles_path}" + fi + done } archive_files_date() { - local source_path=$1 + local source_path="$1" - local epoch_path="$source_path/$DOTEPOCH" + local epoch_path="${source_path}/${DOTEPOCH}" - if ! [ -z "$SOURCE_DATE_EPOCH" ] - then - ( - cd "$source_path" - find -exec touch --no-dereference --date="@$SOURCE_DATE_EPOCH" {} \; - ) + if [[ -n "${SOURCE_DATE_EPOCH}" ]]; then + find "${source_path}" -execdir touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" {} + fi } archive_create() { - local archive_path=$1 - local source_path=$2 - local directory=$3 + local archive_path="$1" + local source_path="$2" + local directory="$3" - local tarfiles_path="$source_path/$DOTTARFILES" - local directory_path=$( dirname "$archive_path" ) + local tarfiles_path="${source_path}/${DOTTARFILES}" + local directory_path="$(dirname "${archive_path}")" - mkdir -p "$directory_path" + mkdir -p "${directory_path}" - if [ -z "$directory" ] - then - directory=$( basename "$source_path" ) + if [[ -z "${directory}" ]]; then + directory="$(basename "${source_path}")" fi - archive_files_create "$source_path" - archive_files_date "$source_path" + archive_files_create "${source_path}" + archive_files_date "${source_path}" + + local tar_options=( + --create + --xz + --file="${archive_path}" + --files-from="${tarfiles_path}" + --transform="s,^,${directory}/,S" + --no-recursion + --null + --owner=0 + --group=0 + --numeric-owner + ) ( - cd "$source_path" - tar -cJf "$archive_path" --no-recursion -T "$tarfiles_path" --transform="s,^,$directory/,S" --owner=root --group=root --numeric-owner + cd "${source_path}" + tar "${tar_options[@]}" ) } archive_extract() { - local archive_path=$1 - local destination_path=$2 + local archive_path="$1" + local destination_path="$2" - if [ -z "$destination_path" ] - then - destination_path=$( dirname "$archive_path" ) + if [[ -z "${destination_path}" ]]; then + destination_path="$(dirname "${archive_path}")" fi - tar -xf "$archive_path" -ps -C "$destination_path" + tar -xf "${archive_path}" -ps -C "${destination_path}" } rootfs_files_create() { - local source_path=$1 - - local directory=$( basename "$source_path" ) - local tarfiles_path="$source_path/$DOTTARFILES" + local source_path="$1" - touch "$tarfiles_path" + local directory="$(basename "${source_path}")" + local tarfiles_path="${source_path}/${DOTTARFILES}" - ( - cd "$source_path" - execute_root find - ) | LC_ALL=C sort | sed "s,^./,," | grep -vP "^$DOTTARFILES|^\.$" > "$tarfiles_path" + # Files in "${tarfiles_path}" are NUL terminated. + # `tr '\0' '\n'` for human-readable output. + execute_root find "${source_path}" -print0 | env LC_ALL='C.UTF-8' sort -z | sed -z "1d;s,^${source_path}/\\?,,;/^${DOTTARFILES}\$/d" > "${tarfiles_path}" } rootfs_files_date() { - local source_path=$1 + local source_path="$1" - local epoch_path="$source_path/$DOTEPOCH" + local epoch_path="${source_path}/${DOTEPOCH}" - if ! [ -z "$SOURCE_DATE_EPOCH" ] - then - ( - cd "$source_path" - execute_root find -exec touch --no-dereference --date="@$SOURCE_DATE_EPOCH" {} \; - ) + if [[ -n "${SOURCE_DATE_EPOCH}" ]]; then + execute_root find "${source_path}" -execdir touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" {} + fi } rootfs_create() { - local rootfs_path=$1 - local source_path=$2 - local directory=$3 + local rootfs_path="$1" + local source_path="$2" + local directory="$3" - local tarfiles_path="$source_path/$DOTTARFILES" - local directory_path=$( dirname "$rootfs_path" ) + local tarfiles_path="${source_path}/${DOTTARFILES}" + local directory_path="$(dirname "${rootfs_path}")" - mkdir -p "$directory_path" + mkdir -p "${directory_path}" - if [ -z "$directory" ] - then - directory=$( basename "$source_path" ) + if [[ -z "${directory}" ]]; then + directory="$(basename "${source_path}")" fi - rootfs_files_create "$source_path" - rootfs_files_date "$source_path" + rootfs_files_create "${source_path}" + rootfs_files_date "${source_path}" + + local tar_options=( + --create + --xz + --file="${rootfs_path}" + --files-from="${tarfiles_path}" + --no-recursion + --null + --owner=0 + --group=0 + --numeric-owner + ) ( - cd "$source_path" - execute_root tar -cJf "$rootfs_path" --no-recursion -T "$tarfiles_path" --numeric-owner + cd "${source_path}" + execute_root tar "${tar_options[@]}" ) - execute_root chmod 644 "$rootfs_path" - execute_root chown $USER:$USER "$rootfs_path" + execute_root chmod 644 "${rootfs_path}" + execute_root chown "${USER}:${USER}" "${rootfs_path}" } requirements() { @@ -331,7 +336,7 @@ requirements() { if [ -z "$requirement_path" ] then - printf "Missing requirement: $requirement\n" >&2 + printf '%s\n' "Missing requirement: $requirement" >&2 exit 1 fi done @@ -348,7 +353,7 @@ requirements_root() { if [ -z "$requirement_path" ] then - printf "Missing requirement: $requirement\n" >&2 + printf '%s\n' "Missing requirement: $requirement" >&2 exit 1 fi done @@ -370,22 +375,22 @@ arguments_concat() { fi done - echo "$concat" + printf '%s\n' "$concat" } execute_root() { local sudo=$( which sudo 2> /dev/null || true ) local arguments - printf "Running command as root: " >&2 - echo "$@" >&2 + printf '%s' 'Running command as root: ' >&2 + printf '%b\n' "$*" >&2 if ! [ -z "$sudo" ] then sudo "$@" else # Quote arguments for eval through su. - arguments=$( printf "%q " "$@" ) + arguments=$( printf '%q ' "$@" ) su -c "$arguments" fi } @@ -202,19 +202,19 @@ git_describe() { } git_files() { - local repository_path=$1 + local repository_path="$1" ( - cd "$repository_path" + cd "${repository_path}" # Reproducible sorting. - git ls-files | LC_ALL=C sort -z + git ls-files -z | env LC_ALL='C.UTF-8' sort -z ) } git_project_repository_path() { local repository=$1 - echo "$root/$SOURCES/$repository" + printf '%s\n' "$root/$SOURCES/$repository" } git_project_check() { @@ -582,7 +582,7 @@ git_project_release() { local archive_path="$root/$RELEASE/$SOURCES/$project/$release_branch.$TAR_XZ" local sources_path="$root/$SOURCES/$repository" - printf "Releasing sources archive for $project (with ${arguments:-no argument}) from "$repository" git\n" + printf '%s\n' "Releasing sources archive for $project (with ${arguments:-no argument}) from "$repository" git" git_branch_checkout "$repository_path" "$release_branch" git_submodule_update "$repository_path" diff --git a/libs/project b/libs/project index 20a6fe77..dc2e056f 100755 --- a/libs/project +++ b/libs/project @@ -17,7 +17,7 @@ PROJECT_ACTIONS_GENERIC="usage download extract update build install release clean" PROJECT_ACTIONS_HELPERS="arguments" -PROJECT_FUNCTIONS=$( for action in $PROJECT_ACTIONS_GENERIC ; do echo "$action" "$action""_check" ; done ; echo "$PROJECT_ACTIONS_HELPERS" ) +PROJECT_FUNCTIONS=$( for action in $PROJECT_ACTIONS_GENERIC ; do printf '%s\n' "$action" "$action""_check" ; done ; printf '%s\n' "$PROJECT_ACTIONS_HELPERS" ) INSTALL_REGEX="\([^:]*\):\(.*\)" @@ -81,7 +81,7 @@ project_action() { if ! project_check "$project" then - printf "Project $project check failed\n" >&2 + printf '%s\n' "Project $project check failed" >&2 return 1 fi @@ -100,7 +100,7 @@ project_action() { return 0 fi - printf "Project $project $action (with ${arguments:-no argument})\n" >&2 + printf '%s\n' "Project $project $action (with ${arguments:-no argument})" >&2 ( set -e @@ -109,10 +109,10 @@ project_action() { if [ $? -ne 0 ] then - printf "\nProject $project $action (with ${arguments:-no argument}) failed\n" >&2 + printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed" >&2 return 1 else - printf "\nProject $project $action (with ${arguments:-no argument}) completed\n" >&2 + printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) completed" >&2 fi ) } @@ -128,7 +128,7 @@ project_action_check() { if ! project_check "$project" then - printf "Project $project check failed\n" >&2 + printf '%s\n' "Project $project check failed" >&2 return 1 fi @@ -165,7 +165,7 @@ project_action_helper() { if ! project_check "$project" then - printf "Project $project check failed\n" >&2 + printf '%s\n' "Project $project check failed" >&2 return 1 fi @@ -221,11 +221,11 @@ project_action_arguments_verify_recursive() { if ! [ -z "$action_helper_arguments" ] then - test=$( echo "$action_helper_arguments" | grep -P "^$argument$" || true ) + test=$( printf '%s\n' "$action_helper_arguments" | grep -P "^$argument$" || true ) if [ -z "$test" ] then - printf "Invalid argument $argument for project $project action $action\n" >&2 + printf '%s\n' "Invalid argument $argument for project $project action $action" >&2 return 1 fi fi @@ -253,7 +253,7 @@ project_action_arguments_recursive() { ifs_save=$IFS IFS=$'\n' - for argument in $( echo "$action_helper_arguments" ) + for argument in $( printf '%s\n' "$action_helper_arguments" ) do ( IFS=$ifs_save @@ -298,7 +298,7 @@ project_path() { local project_path="$root/$PROJECTS/$project" - echo "$project_path" + printf '%s\n' "$project_path" } project_sources_path() { @@ -331,7 +331,7 @@ project_sources_path() { if ! [ -z "$sources_path" ] then - echo "$sources_path" + printf '%s\n' "$sources_path" return fi @@ -340,7 +340,7 @@ project_sources_path() { if directory_filled_check "$path" then - echo "$path" + printf '%s\n' "$path" return fi @@ -364,7 +364,7 @@ project_sources_path() { if ! [ -z "$sources_path" ] then - echo "$sources_path" + printf '%s\n' "$sources_path" return fi } @@ -387,7 +387,7 @@ project_sources_directory_filled_error() { if ! [ -z "$sources_path" ] then - printf "Sources directory for project $project (with ${arguments:-no argument}) already exists\n" >&2 + printf '%s\n' "Sources directory for project $project (with ${arguments:-no argument}) already exists" >&2 return 1 else return 0 @@ -403,7 +403,7 @@ project_sources_directory_missing_empty_error() { if [ -z "$sources_path" ] then - printf "Sources directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2 + printf '%s\n' "Sources directory for project $project (with ${arguments:-no argument}) missing or empty" >&2 return 1 else return 0 @@ -437,7 +437,7 @@ project_sources_archive() { if ! [ -z "$sources_archive" ] then - echo "$sources_archive" + printf '%s\n' "$sources_archive" fi } @@ -449,7 +449,7 @@ project_sources_archive_extract() { local archive=$( project_sources_archive "$project" "$@" ) local destination=$( dirname "$archive" ) - printf "Extracting source archive for $project (with ${arguments:-no argument})\n" + printf '%s\n' "Extracting source archive for $project (with ${arguments:-no argument})" file_verification_check "$archive" archive_extract "$archive" "$destination" @@ -470,7 +470,7 @@ project_sources_archive_update() { rm -rf "$sources_path" fi - printf "Extracting source archive for $project (with ${arguments:-no argument})\n" + printf '%s\n' "Extracting source archive for $project (with ${arguments:-no argument})" file_verification_check "$archive" archive_extract "$archive" "$destination" @@ -484,7 +484,7 @@ project_sources_archive_missing_error() { local archive=$( project_sources_archive "$project" "$@" ) if [ -z "$archive" ] || ! [ -f "$archive" ] then - printf "Missing sources archive for $project (with ${arguments:-no argument})\n" >&2 + printf '%s\n' "Missing sources archive for $project (with ${arguments:-no argument})" >&2 return 1 else return 0 @@ -529,12 +529,12 @@ project_blobs_path() { if [ -f "$blobs_path" ] then - echo "$blobs_path" + printf '%s\n' "$blobs_path" return fi done - echo "$blobs_path" + printf '%s\n' "$blobs_path" } project_blobs_ignore_path() { @@ -562,7 +562,7 @@ project_blobs_ignore_path() { if [ -f "$blobs_ignore_path" ] then - echo "$blobs_ignore_path" + printf '%s\n' "$blobs_ignore_path" return fi done @@ -593,23 +593,23 @@ project_usage_actions() { local project=$1 shift - printf "\nGeneric actions:\n" + printf '\n%s\n' 'Generic actions:' for action in $PROJECT_ACTIONS_GENERIC do if function_check "$action" then - printf " $action\n" + printf '%s\n' " $action" fi done if [ $# -gt 0 ] then - printf "\nSpecific actions:\n" + printf '\n%s\n' 'Specific actions:' for action in "$@" do - printf " $action\n" + printf '%s\n' " $action" done fi } @@ -618,7 +618,7 @@ project_usage_arguments() { local project=$1 shift - printf "\nArguments:\n" + printf '\n%s\n' 'Arguments:' project_usage_arguments_recursive "$project" " " "$@" } @@ -636,9 +636,9 @@ project_usage_arguments_recursive() { if ! [ -z "$action_helper_arguments" ] then - echo "$action_helper_arguments" | while read argument + printf '%s\n' "$action_helper_arguments" | while read argument do - printf "$spacing$argument\n" + printf '%s\n' "$spacing$argument" project_usage_arguments_recursive "$project" " $spacing" "$@" "$argument" done fi @@ -769,7 +769,7 @@ project_build_check() { while read rule do - source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) + source=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) source_path="$build_path/$source" # Source may contain a wildcard. @@ -796,7 +796,7 @@ project_build_path() { build_path="$build_path-$argument" done - echo "$build_path" + printf '%s\n' "$build_path" } project_build_directory_missing_empty_error() { @@ -808,7 +808,7 @@ project_build_directory_missing_empty_error() { if ! directory_filled_check "$build_path" then - printf "Build directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2 + printf '%s\n' "Build directory for project $project (with ${arguments:-no argument}) missing or empty" >&2 return 1 else return 0 @@ -851,10 +851,10 @@ project_install() { while read rule do - source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) + source=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) source_path="$build_path/$source" - destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) + destination=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) destination_path="$install_path/$destination" destination_directory_path=$( dirname "$destination_path" ) @@ -892,10 +892,10 @@ project_install() { while read rule do - source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) + source=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) source_path="$project_path/$INSTALL/$path/$source" - destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) + destination=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) destination_path="$install_path/$destination" destination_directory_path=$( dirname "$destination_path" ) @@ -945,7 +945,7 @@ project_install_check() { while read rule do - destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) + destination=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) destination_path="$install_path/$destination" if ! [ -f "$destination_path" ] && ! [ -d "$destination_path" ] @@ -979,7 +979,7 @@ project_install_check() { while read rule do - destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) + destination=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) destination_path="$install_path/$destination" if ! [ -f "$destination_path" ] && ! [ -d "$destination_path" ] @@ -1002,7 +1002,7 @@ project_install_path() { install_path="$install_path-$argument" done - echo "$install_path" + printf '%s\n' "$install_path" } project_install_directory_missing_empty_error() { @@ -1014,7 +1014,7 @@ project_install_directory_missing_empty_error() { if ! directory_filled_check "$install_path" then - printf "Install directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2 + printf '%s\n' "Install directory for project $project (with ${arguments:-no argument}) missing or empty" >&2 return 1 else return 0 @@ -1038,7 +1038,7 @@ project_release_path() { release_path="$release_path/$project" fi - echo "$release_path" + printf '%s\n' "$release_path" } project_release_archive_path() { @@ -1058,7 +1058,7 @@ project_release_archive_path() { local archive_path="$release_path/$path.$TAR_XZ" - echo "$archive_path" + printf '%s\n' "$archive_path" } project_release_rootfs_path() { @@ -1078,7 +1078,7 @@ project_release_rootfs_path() { local rootfs_path="$release_path/$path.$TAR_XZ" - echo "$rootfs_path" + printf '%s\n' "$rootfs_path" } project_release_sources_archive_path() { @@ -1111,7 +1111,7 @@ project_release_sources_archive_path() { then local archive_path="$root/$RELEASE/$SOURCES/$project/$release_path.$TAR_XZ" - echo "$archive_path" + printf '%s\n' "$archive_path" fi } @@ -1124,7 +1124,7 @@ project_release_sources_archive_create() { local archive_path=$( project_release_sources_archive_path "$project" "$@" ) local sources_path=$( project_sources_path "$project" "$repository" "$@" ) - printf "Releasing sources archive for $project (with ${arguments:-no argument})\n" + printf '%s\n' "Releasing sources archive for $project (with ${arguments:-no argument})" archive_create "$archive_path" "$sources_path" file_verification_create "$archive_path" @@ -1199,7 +1199,7 @@ project_release_install() { local files=$( cd "$install_path" && find -type f || true ) local file - echo "$files" | while read file + printf '%s\n' "$files" | while read file do path="$release_path/$file" directory_path=$( dirname "$path" ) @@ -1226,7 +1226,7 @@ project_release_install_check() { local files=$( cd "$install_path" && find -type f || true ) local file - echo "$files" | while read file + printf '%s\n' "$files" | while read file do path="$release_path/$file" @@ -1262,7 +1262,7 @@ project_release_install_archive_create() { local install_path=$( project_install_path "$project" "$@" ) local archive_path=$( project_release_archive_path "$project" "$prefix" "$@" ) - printf "Releasing $prefix archive for $project (with ${arguments:-no argument})\n" + printf '%s\n' "Releasing $prefix archive for $project (with ${arguments:-no argument})" archive_create "$archive_path" "$install_path" file_verification_create "$archive_path" @@ -1310,7 +1310,7 @@ project_release_install_rootfs_create() { local install_path=$( project_install_path "$project" "$@" ) local rootfs_path=$( project_release_rootfs_path "$project" "$prefix" "$@" ) - printf "Releasing $prefix rootfs for $project (with ${arguments:-no argument})\n" + printf '%s\n' "Releasing $prefix rootfs for $project (with ${arguments:-no argument})" rootfs_create "$rootfs_path" "$install_path" file_verification_create "$rootfs_path" @@ -1421,7 +1421,7 @@ project_file_path() { return 1 fi - echo "$file_path" + printf '%s\n' "$file_path" } project_file_test() { @@ -17,7 +17,7 @@ TOOL_ACTIONS_GENERIC="usage update execute" TOOL_ACTIONS_HELPERS="arguments" -TOOL_FUNCTIONS=$( for action in $TOOL_ACTIONS_GENERIC ; do echo "$action" "$action""_check" ; done ; echo "$TOOL_ACTIONS_HELPERS" ) +TOOL_FUNCTIONS=$( for action in $TOOL_ACTIONS_GENERIC ; do printf '%s\n' "$action" "$action""_check" ; done ; printf '%s\n' "$TOOL_ACTIONS_HELPERS" ) tool_include() { local tool=$1 @@ -79,7 +79,7 @@ tool_action() { if ! tool_check "$tool" then - printf "Tool $tool check failed\n" >&2 + printf '%s\n' "Tool $tool check failed" >&2 return 1 fi @@ -97,7 +97,7 @@ tool_action() { return 0 fi - printf "Tool $tool $action (with ${arguments:-no argument})\n" >&2 + printf '%s\n' "Tool $tool $action (with ${arguments:-no argument})" >&2 ( set -e @@ -106,10 +106,10 @@ tool_action() { if [ $? -ne 0 ] then - printf "\nTool $tool $action (with ${arguments:-no argument}) failed\n" >&2 + printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) failed" >&2 return 1 else - printf "\nTool $tool $action (with ${arguments:-no argument}) completed\n" >&2 + printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) completed" >&2 fi ) } @@ -125,7 +125,7 @@ tool_action_check() { if ! tool_check "$tool" then - printf "Tool $tool check failed\n" >&2 + printf '%s\n' "Tool $tool check failed" >&2 return 1 fi @@ -162,7 +162,7 @@ tool_action_helper() { if ! tool_check "$tool" then - printf "Tool $tool check failed\n" >&2 + printf '%s\n' "Tool $tool check failed" >&2 return 1 fi @@ -193,7 +193,7 @@ tool_action_arguments_recursive() { then tool_action "$action" "$tool" "$@" else - echo "$action_helper_arguments" | while read argument + printf '%s\n' "$action_helper_arguments" | while read argument do tool_action_arguments_recursive "$action" "$tool" "$@" "$argument" done @@ -205,7 +205,7 @@ tool_path() { local tool_path="$root/$TOOLS/$tool" - echo "$tool_path" + printf '%s\n' "$tool_path" } tool_sources_path() { @@ -224,7 +224,7 @@ tool_sources_path() { if directory_filled_check "$path" then - echo "$path" + printf '%s\n' "$path" return fi done @@ -234,23 +234,23 @@ tool_usage_actions() { local tool=$1 shift - printf "\nGeneric actions:\n" + printf '\n%s\n' 'Generic actions:' for action in $TOOL_ACTIONS_GENERIC do if function_check "$action" then - printf " $action\n" + printf '%s\n' " $action" fi done if [ $# -gt 0 ] then - printf "\nSpecific actions:\n" + printf '\n%s\n' 'Specific actions:' for action in "$@" do - printf " $action\n" + printf '%s\n' " $action" done fi } @@ -259,7 +259,7 @@ tool_usage_arguments() { local tool=$1 shift - printf "\nArguments:\n" + printf '\n%s\n' 'Arguments:' tool_usage_arguments_recursive "$tool" " " "$@" } @@ -275,9 +275,9 @@ tool_usage_arguments_recursive() { if ! [ -z "$action_helper_arguments" ] then - echo "$action_helper_arguments" | while read argument + printf '%s\n' "$action_helper_arguments" | while read argument do - printf "$spacing$argument\n" + printf '%s\n' "$spacing$argument" tool_usage_arguments_recursive "$tool" " $spacing" "$@" "$argument" done fi @@ -316,7 +316,7 @@ tool_file_path() { return 1 fi - echo "$file_path" + printf '%s\n' "$file_path" } tool_file_test() { |