From 4e50a92041c9f30deef1a32c995b9d5634cbed22 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Fri, 23 Jun 2017 13:55:22 -0400 Subject: Remove unnecessary 'env' invocation from printf. This reverts part of pull request #217 which called the 'env' binary for each printf invocation. --- libs/common | 20 ++++++------ libs/git | 4 +-- libs/project | 102 +++++++++++++++++++++++++++++------------------------------ libs/tool | 36 ++++++++++----------- 4 files changed, 81 insertions(+), 81 deletions(-) (limited to 'libs') diff --git a/libs/common b/libs/common index bcae2a9d..ce0df299 100755 --- a/libs/common +++ b/libs/common @@ -60,7 +60,7 @@ arguments_list() { for argument in "$@" do - env printf '%s\n' "$argument" + printf '%s\n' "$argument" done } @@ -85,7 +85,7 @@ path_wildcard_expand() { local path=$@ # Evaluation fails with unescaped whitespaces. - path=$( env printf '%s\n' "$path" | sed "s/ /\\\ /g" ) + path=$( printf '%s\n' "$path" | sed "s/ /\\\ /g" ) eval "arguments_list "$path"" } @@ -112,7 +112,7 @@ file_checksum_check() { if ! [ -f "$checksum_path" ] then - env printf '%s\n' 'Could not verify file checksum!' >&2 + printf '%s\n' 'Could not verify file checksum!' >&2 return 1 fi @@ -142,7 +142,7 @@ file_signature_check() { if ! [ -f "$signature_path" ] then - env printf '%s\n' 'Could not verify file signature!' >&2 + printf '%s\n' 'Could not verify file signature!' >&2 return 1 fi @@ -336,7 +336,7 @@ requirements() { if [ -z "$requirement_path" ] then - env printf '%s\n' "Missing requirement: $requirement" >&2 + printf '%s\n' "Missing requirement: $requirement" >&2 exit 1 fi done @@ -353,7 +353,7 @@ requirements_root() { if [ -z "$requirement_path" ] then - env printf '%s\n' "Missing requirement: $requirement" >&2 + printf '%s\n' "Missing requirement: $requirement" >&2 exit 1 fi done @@ -375,22 +375,22 @@ arguments_concat() { fi done - env printf '%s\n' "$concat" + printf '%s\n' "$concat" } execute_root() { local sudo=$( which sudo 2> /dev/null || true ) local arguments - env printf '%s' 'Running command as root: ' >&2 - env printf '%b\n' "$*" >&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=$( env printf '%q ' "$@" ) + arguments=$( printf '%q ' "$@" ) su -c "$arguments" fi } diff --git a/libs/git b/libs/git index 1590e9a7..e62c22e3 100755 --- a/libs/git +++ b/libs/git @@ -214,7 +214,7 @@ git_files() { git_project_repository_path() { local repository=$1 - env printf '%s\n' "$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" - env printf '%s\n' "Releasing sources archive for $project (with ${arguments:-no argument}) from "$repository" git" + 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 b8d7862b..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 env printf '%s\n' "$action" "$action""_check" ; done ; env printf '%s\n' "$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 - env printf '%s\n' "Project $project check failed" >&2 + printf '%s\n' "Project $project check failed" >&2 return 1 fi @@ -100,7 +100,7 @@ project_action() { return 0 fi - env printf '%s\n' "Project $project $action (with ${arguments:-no argument})" >&2 + printf '%s\n' "Project $project $action (with ${arguments:-no argument})" >&2 ( set -e @@ -109,10 +109,10 @@ project_action() { if [ $? -ne 0 ] then - env printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed" >&2 + printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed" >&2 return 1 else - env printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) completed" >&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 - env printf '%s\n' "Project $project check failed" >&2 + printf '%s\n' "Project $project check failed" >&2 return 1 fi @@ -165,7 +165,7 @@ project_action_helper() { if ! project_check "$project" then - env printf '%s\n' "Project $project check failed" >&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=$( env printf '%s\n' "$action_helper_arguments" | grep -P "^$argument$" || true ) + test=$( printf '%s\n' "$action_helper_arguments" | grep -P "^$argument$" || true ) if [ -z "$test" ] then - env printf '%s\n' "Invalid argument $argument for project $project action $action" >&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 $( env printf '%s\n' "$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" - env printf '%s\n' "$project_path" + printf '%s\n' "$project_path" } project_sources_path() { @@ -331,7 +331,7 @@ project_sources_path() { if ! [ -z "$sources_path" ] then - env printf '%s\n' "$sources_path" + printf '%s\n' "$sources_path" return fi @@ -340,7 +340,7 @@ project_sources_path() { if directory_filled_check "$path" then - env printf '%s\n' "$path" + printf '%s\n' "$path" return fi @@ -364,7 +364,7 @@ project_sources_path() { if ! [ -z "$sources_path" ] then - env printf '%s\n' "$sources_path" + printf '%s\n' "$sources_path" return fi } @@ -387,7 +387,7 @@ project_sources_directory_filled_error() { if ! [ -z "$sources_path" ] then - env printf '%s\n' "Sources directory for project $project (with ${arguments:-no argument}) already exists" >&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 - env printf '%s\n' "Sources directory for project $project (with ${arguments:-no argument}) missing or empty" >&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 - env printf '%s\n' "$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" ) - env printf '%s\n' "Extracting source archive for $project (with ${arguments:-no argument})" + 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 - env printf '%s\n' "Extracting source archive for $project (with ${arguments:-no argument})" + 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 - env printf '%s\n' "Missing sources archive for $project (with ${arguments:-no argument})" >&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 - env printf '%s\n' "$blobs_path" + printf '%s\n' "$blobs_path" return fi done - env printf '%s\n' "$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 - env printf '%s\n' "$blobs_ignore_path" + printf '%s\n' "$blobs_ignore_path" return fi done @@ -593,23 +593,23 @@ project_usage_actions() { local project=$1 shift - env printf '\n%s\n' 'Generic actions:' + printf '\n%s\n' 'Generic actions:' for action in $PROJECT_ACTIONS_GENERIC do if function_check "$action" then - env printf '%s\n' " $action" + printf '%s\n' " $action" fi done if [ $# -gt 0 ] then - env printf '\n%s\n' 'Specific actions:' + printf '\n%s\n' 'Specific actions:' for action in "$@" do - env printf '%s\n' " $action" + printf '%s\n' " $action" done fi } @@ -618,7 +618,7 @@ project_usage_arguments() { local project=$1 shift - env printf '\n%s\n' 'Arguments:' + printf '\n%s\n' 'Arguments:' project_usage_arguments_recursive "$project" " " "$@" } @@ -636,9 +636,9 @@ project_usage_arguments_recursive() { if ! [ -z "$action_helper_arguments" ] then - env printf '%s\n' "$action_helper_arguments" | while read argument + printf '%s\n' "$action_helper_arguments" | while read argument do - env printf '%s\n' "$spacing$argument" + 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=$( env printf '%s\n' "$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 - env printf '%s\n' "$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 - env printf '%s\n' "Build directory for project $project (with ${arguments:-no argument}) missing or empty" >&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=$( env printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) + source=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) source_path="$build_path/$source" - destination=$( env printf '%s\n' "$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=$( env printf '%s\n' "$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=$( env printf '%s\n' "$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=$( env printf '%s\n' "$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=$( env printf '%s\n' "$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 - env printf '%s\n' "$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 - env printf '%s\n' "Install directory for project $project (with ${arguments:-no argument}) missing or empty" >&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 - env printf '%s\n' "$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" - env printf '%s\n' "$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" - env printf '%s\n' "$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" - env printf '%s\n' "$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" "$@" ) - env printf '%s\n' "Releasing sources archive for $project (with ${arguments:-no argument})" + 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 - env printf '%s\n' "$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 - env printf '%s\n' "$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" "$@" ) - env printf '%s\n' "Releasing $prefix archive for $project (with ${arguments:-no argument})" + 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" "$@" ) - env printf '%s\n' "Releasing $prefix rootfs for $project (with ${arguments:-no argument})" + 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 - env printf '%s\n' "$file_path" + printf '%s\n' "$file_path" } project_file_test() { diff --git a/libs/tool b/libs/tool index f3479c48..77517dda 100755 --- a/libs/tool +++ b/libs/tool @@ -17,7 +17,7 @@ TOOL_ACTIONS_GENERIC="usage update execute" TOOL_ACTIONS_HELPERS="arguments" -TOOL_FUNCTIONS=$( for action in $TOOL_ACTIONS_GENERIC ; do env printf '%s\n' "$action" "$action""_check" ; done ; env printf '%s\n' "$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 - env printf '%s\n' "Tool $tool check failed" >&2 + printf '%s\n' "Tool $tool check failed" >&2 return 1 fi @@ -97,7 +97,7 @@ tool_action() { return 0 fi - env printf '%s\n' "Tool $tool $action (with ${arguments:-no argument})" >&2 + printf '%s\n' "Tool $tool $action (with ${arguments:-no argument})" >&2 ( set -e @@ -106,10 +106,10 @@ tool_action() { if [ $? -ne 0 ] then - env printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) failed" >&2 + printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) failed" >&2 return 1 else - env printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) completed" >&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 - env printf '%s\n' "Tool $tool check failed" >&2 + printf '%s\n' "Tool $tool check failed" >&2 return 1 fi @@ -162,7 +162,7 @@ tool_action_helper() { if ! tool_check "$tool" then - env printf '%s\n' "Tool $tool check failed" >&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 - env printf '%s\n' "$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" - env printf '%s\n' "$tool_path" + printf '%s\n' "$tool_path" } tool_sources_path() { @@ -224,7 +224,7 @@ tool_sources_path() { if directory_filled_check "$path" then - env printf '%s\n' "$path" + printf '%s\n' "$path" return fi done @@ -234,23 +234,23 @@ tool_usage_actions() { local tool=$1 shift - env printf '\n%s\n' 'Generic actions:' + printf '\n%s\n' 'Generic actions:' for action in $TOOL_ACTIONS_GENERIC do if function_check "$action" then - env printf '%s\n' " $action" + printf '%s\n' " $action" fi done if [ $# -gt 0 ] then - env printf '\n%s\n' 'Specific actions:' + printf '\n%s\n' 'Specific actions:' for action in "$@" do - env printf '%s\n' " $action" + printf '%s\n' " $action" done fi } @@ -259,7 +259,7 @@ tool_usage_arguments() { local tool=$1 shift - env printf '\n%s\n' 'Arguments:' + printf '\n%s\n' 'Arguments:' tool_usage_arguments_recursive "$tool" " " "$@" } @@ -275,9 +275,9 @@ tool_usage_arguments_recursive() { if ! [ -z "$action_helper_arguments" ] then - env printf '%s\n' "$action_helper_arguments" | while read argument + printf '%s\n' "$action_helper_arguments" | while read argument do - env printf '%s\n' "$spacing$argument" + printf '%s\n' "$spacing$argument" tool_usage_arguments_recursive "$tool" " $spacing" "$@" "$argument" done fi @@ -316,7 +316,7 @@ tool_file_path() { return 1 fi - env printf '%s\n' "$file_path" + printf '%s\n' "$file_path" } tool_file_test() { -- cgit v1.2.3-70-g09d2