aboutsummaryrefslogtreecommitdiff
path: root/libs/tool
diff options
context:
space:
mode:
authorAndrew Robbins <contact@andrewrobbins.info>2017-07-12 12:32:14 -0400
committerAndrew Robbins <contact@andrewrobbins.info>2017-07-14 15:16:05 -0400
commit547be866932ec92ca818a7ed661519dd9be598d5 (patch)
tree646cb7412cd51cdfe6da65a6d6deeb49df97f298 /libs/tool
parent8c7d21cbf45a4279dcffae95ce626a0dc9006a30 (diff)
downloadlibrebootfr-547be866932ec92ca818a7ed661519dd9be598d5.tar.gz
librebootfr-547be866932ec92ca818a7ed661519dd9be598d5.zip
Rely less on word splitting by using arrays
Arrays are just a better idea for storing multiple strings than relying on word splitting. Consequently, several global variables in libs/* were switched to arrays and any references to said variables modified to expand to the arrays' elements.
Diffstat (limited to 'libs/tool')
-rwxr-xr-xlibs/tool14
1 files changed, 9 insertions, 5 deletions
diff --git a/libs/tool b/libs/tool
index 8d067d94..0f9fb063 100755
--- a/libs/tool
+++ b/libs/tool
@@ -15,16 +15,20 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TOOL_ACTIONS_GENERIC="usage update execute"
-TOOL_ACTIONS_HELPERS="arguments"
-TOOL_FUNCTIONS=$( for action in $TOOL_ACTIONS_GENERIC ; do printf '%s\n' "$action" "$action""_check" ; done ; printf '%s\n' "$TOOL_ACTIONS_HELPERS" )
+TOOL_ACTIONS_GENERIC=(usage update execute)
+TOOL_ACTIONS_HELPERS=(arguments)
+TOOL_ACTIONS_FUNCTIONS=(
+ "${TOOL_ACTIONS_GENERIC[@]}"
+ "${TOOL_ACTIONS_GENERIC[@]/%/_check}"
+ "${TOOL_ACTIONS_HELPERS[@]}"
+)
tool_include() {
local tool=$1
local tool_path=$( tool_path "$tool" )
- unset -f $TOOL_FUNCTIONS
+ unset -f "${TOOL_ACTIONS_FUNCTIONS[@]}"
. "$tool_path/$tool"
@@ -236,7 +240,7 @@ tool_usage_actions() {
printf '\n%s\n' 'Generic actions:'
- for action in $TOOL_ACTIONS_GENERIC
+ for action in "${TOOL_ACTIONS_GENERIC[@]}"
do
if function_check "$action"
then