aboutsummaryrefslogtreecommitdiff
path: root/libs/tool
diff options
context:
space:
mode:
Diffstat (limited to 'libs/tool')
-rwxr-xr-xlibs/tool60
1 files changed, 30 insertions, 30 deletions
diff --git a/libs/tool b/libs/tool
index 8ed70e18..2732238a 100755
--- a/libs/tool
+++ b/libs/tool
@@ -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