From 5e3dcd8f29cf4ad653e69d50e1500a330bba8ca8 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Sat, 22 Jul 2017 01:51:01 -0400 Subject: Remove IFS binding masking a non-zero status code In project_action_arguments_recursive(), IFS bindings needed to be reworked in order to avoid a situation where, for example, project_extract() would fail to extract source archives (because they didn't exist), returning a status code of 1 only for it to be masked by a rebinding of IFS--which would always succeed. ifs_save and IFS were made local variables in project_action_arguments_recursive() in order to avoid the need to rebind IFS after the for loop returns. This patch makes './libreboot sources ' functional. --- libs/project | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libs/project b/libs/project index 8eaf0d2d..728b9118 100755 --- a/libs/project +++ b/libs/project @@ -187,16 +187,15 @@ project_action_arguments_recursive() { local action_helper_arguments local argument - local ifs_save action_helper_arguments="$(project_action_helper 'arguments' "${project}" "$@" || true)" if [[ -z "${action_helper_arguments}" ]]; then project_action "${action}" "${project}" "$@" else - # This it to allow space characters in arguments. - ifs_save="${IFS}" - IFS=$'\n' + # This is to allow space characters in arguments. + local ifs_save="${IFS}" + local IFS=$'\n' for argument in $(printf '%s\n' "${action_helper_arguments}") do @@ -207,8 +206,6 @@ project_action_arguments_recursive() { project_action_arguments_recursive "${action}" "${project}" "$@" "${argument}" ) done - - IFS="${ifs_save}" fi } -- cgit v1.2.3-70-g09d2 From 4aff8835cdd469f94a3ed30bfc3f0c0e3badd96f Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Sat, 22 Jul 2017 01:58:23 -0400 Subject: Remove unnecessary subshell grouping --- libs/project | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/project b/libs/project index 728b9118..2efd7afb 100755 --- a/libs/project +++ b/libs/project @@ -199,12 +199,10 @@ project_action_arguments_recursive() { for argument in $(printf '%s\n' "${action_helper_arguments}") do - ( - IFS="${ifs_save}" + IFS="${ifs_save}" - # Only a single argument at a time is returned by the helper. - project_action_arguments_recursive "${action}" "${project}" "$@" "${argument}" - ) + # Only a single argument at a time is returned by the helper. + project_action_arguments_recursive "${action}" "${project}" "$@" "${argument}" done fi } -- cgit v1.2.3-70-g09d2 From 308b5eefe3a3a586347c47970a01bb2bac4cb951 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Sat, 22 Jul 2017 02:07:24 -0400 Subject: Skip archive extraction if archive doesn't exist --- libs/project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/project b/libs/project index 2efd7afb..ab56feba 100755 --- a/libs/project +++ b/libs/project @@ -680,7 +680,7 @@ project_extract() { if ! project_sources_directory_filled_check "$project" "$repository" "$@" then - project_sources_archive_missing_error "$project" "$@" + project_sources_archive_missing_error "$project" "$@" || return 1 project_sources_archive_extract "$project" "$@" fi } -- cgit v1.2.3-70-g09d2 From 5abde443b2bdae7723b046f3db3b8e821ab67cde Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Sat, 22 Jul 2017 02:10:25 -0400 Subject: Make 'sources' consequent prettier Removes an unnecessary subshell grouping and 'set' statement and replaces it with a good ol' if/then/else construct. Also added a message printed to stdout informing the user of the change from extraction to downloading if source extraction fails. --- libreboot | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libreboot b/libreboot index 59795d09..73176858 100755 --- a/libreboot +++ b/libreboot @@ -78,12 +78,12 @@ libreboot_project() { case "${action}" in 'sources') - ( - set +e - - project_action_arguments 'extract' "${project}" "$@" && return 0 - project_action_arguments 'download' "${project}" "$@" && return 0 - ) + if project_action_arguments 'extract' "${project}" "$@"; then + return + else + printf '\n%s\n\n' 'Attempting to download instead...' + project_action_arguments 'download' "${project}" "$@" + fi ;; 'produce') for action in 'build' 'install' 'release'; do -- cgit v1.2.3-70-g09d2 From 020e60707d88bfaf35aa0550cf662df12d639dc5 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Sat, 22 Jul 2017 02:47:54 -0400 Subject: Add copyright notice --- libreboot | 1 + 1 file changed, 1 insertion(+) diff --git a/libreboot b/libreboot index 73176858..af4c1f49 100755 --- a/libreboot +++ b/libreboot @@ -1,6 +1,7 @@ #!/usr/bin/env bash # Copyright (C) 2016 Paul Kocialkowski +# Copyright (C) 2017 Andrew Robbins # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -- cgit v1.2.3-70-g09d2