diff options
author | Swift Geek <swiftgeek@gmail.com> | 2017-10-29 04:46:17 +0000 |
---|---|---|
committer | Gogs <gogitservice@gmail.com> | 2017-10-29 04:46:17 +0000 |
commit | 5ff0c88449bb5bf03e4e38246565d3272fca1db5 (patch) | |
tree | e86f14dfddc867e8a8abdfa31713edcc2cf87c3d /libs/tool | |
parent | bedc62fdada9e0e7a67b82153b186689dda07145 (diff) | |
parent | 5c1fe562d8044249f5830df826544bc72ecb41b2 (diff) | |
download | librebootfr-5ff0c88449bb5bf03e4e38246565d3272fca1db5.tar.gz librebootfr-5ff0c88449bb5bf03e4e38246565d3272fca1db5.zip |
Merge branch 'readability-changes' of kragle/libreboot into master
Diffstat (limited to 'libs/tool')
-rwxr-xr-x | libs/tool | 60 |
1 files changed, 30 insertions, 30 deletions
@@ -22,11 +22,11 @@ TOOL_ACTIONS_HELPERS=(arguments) tool_include() { local tool=$1 - local tool_path=$( tool_path "$tool" ) + local tool_path=$(tool_path "$tool") unset -f "${TOOL_ACTIONS[@]}" - . "$tool_path/$tool" + source "$tool_path/$tool" tool_helper_include "$tool" } @@ -34,12 +34,12 @@ tool_include() { tool_helper_include() { local tool=$1 - local tool_path=$( tool_path "$tool" ) + local tool_path=$(tool_path "$tool") local include="$tool_path/$tool-helper" - if [ -f "$include" ] + if [[ -f "$include" ]] then - . "$include" + source "$include" fi } @@ -79,13 +79,13 @@ tool_action() { if ! tool_check "$tool" then - printf '%s\n' "Tool $tool check failed" >&2 + printf 1>&2 '%s\n' "Tool $tool check failed" return 1 fi tool_action_check "$action" "$tool" "$@" - if [ $? -eq 0 ] + if [[ $? -eq 0 ]] then return 0 fi @@ -97,19 +97,19 @@ tool_action() { return 0 fi - printf '%s\n' "Tool $tool $action (with ${arguments:-no argument})" >&2 + printf 1>&2 '%s\n' "Tool $tool $action (with ${arguments:-no argument})" ( set -e "$action" "$@" ) - if [ $? -ne 0 ] + if [[ $? -ne 0 ]] then - printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) failed" >&2 + printf 1>&2 '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) failed" return 1 else - printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) completed" >&2 + printf 1>&2 '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) completed" fi ) } @@ -125,7 +125,7 @@ tool_action_check() { if ! tool_check "$tool" then - printf '%s\n' "Tool $tool check failed" >&2 + printf 1>&2 '%s\n' "Tool $tool check failed" return 1 fi @@ -138,7 +138,7 @@ tool_action_check() { for tool_force in $TOOLS_FORCE do - if [ "$tool_force" = "$tool" ] + if [[ "$tool_force" = "$tool" ]] then return 1 fi @@ -162,7 +162,7 @@ tool_action_helper() { if ! tool_check "$tool" then - printf '%s\n' "Tool $tool check failed" >&2 + printf 1>&2 '%s\n' "Tool $tool check failed" return 1 fi @@ -186,10 +186,10 @@ tool_action_arguments_recursive() { local tool=$1 shift - local action_helper_arguments=$( tool_action_helper "arguments" "$tool" "$@" ) + local action_helper_arguments=$(tool_action_helper "arguments" "$tool" "$@") local argument - if [ $? -ne 0 ] || [ -z "$action_helper_arguments" ] + if [[ $? -ne 0 ]] || [[ -z "$action_helper_arguments" ]] then tool_action "$action" "$tool" "$@" else @@ -236,7 +236,7 @@ tool_sources_path() { for argument in "" "$@" do - if ! [ -z "$argument" ] + if [[ -n "$argument" ]] then path="$path/$argument" fi @@ -263,7 +263,7 @@ tool_usage_actions() { fi done - if [ $# -gt 0 ] + if [[ $# -gt 0 ]] then printf '\n%s\n' 'Specific actions:' @@ -289,10 +289,10 @@ tool_usage_arguments_recursive() { local spacing=$1 shift - local action_helper_arguments=$( tool_action_helper "arguments" "$tool" "$@" ) + local action_helper_arguments=$(tool_action_helper "arguments" "$tool" "$@") local argument - if ! [ -z "$action_helper_arguments" ] + if [[ -n "$action_helper_arguments" ]] then printf '%s\n' "$action_helper_arguments" | while read argument do @@ -310,19 +310,19 @@ tool_file_path() { local file=$1 shift - local tool_path=$( tool_path "$tool" ) + local tool_path=$(tool_path "$tool") local path="$tool_path/$directory" local argument local file_path for argument in "" "$@" do - if ! [ -z "$argument" ] + if [[ -n "$argument" ]] then path="$path/$argument" fi - if ! [ -f "$path/$file" ] + if ! [[ -f "$path/$file" ]] then continue fi @@ -330,7 +330,7 @@ tool_file_path() { file_path="$path/$file" done - if [ -z "$file_path" ] + if [[ -z "$file_path" ]] then return 1 fi @@ -339,15 +339,15 @@ tool_file_path() { } tool_file_test() { - local file_path=$( tool_file_path "$@" ) + local file_path=$(tool_file_path "$@") test -f "$file_path" } tool_file_contents() { - local file_path=$( tool_file_path "$@" ) + local file_path=$(tool_file_path "$@") - if [ -f "$file_path" ] + if [[ -f "$file_path" ]] then cat "$file_path" fi @@ -361,21 +361,21 @@ tool_file_contents_herit() { local file=$1 shift - local tool_path=$( tool_path "$tool" ) + local tool_path=$(tool_path "$tool") local path="$tool_path/$directory" local argument local file_path for argument in "" "$@" do - if ! [ -z "$argument" ] + if [[ -n "$argument" ]] then path="$path/$argument" fi file_path="$path/$file" - if ! [ -f "$file_path" ] + if ! [[ -f "$file_path" ]] then continue fi |