aboutsummaryrefslogtreecommitdiff
path: root/libs/project
diff options
context:
space:
mode:
authorAndrew Robbins <contact@andrewrobbins.info>2017-10-26 02:32:54 -0400
committerAndrew Robbins <contact@andrewrobbins.info>2017-10-28 23:30:01 -0400
commit85934d62d767a484fa560066b6edb69a18145690 (patch)
tree8136b2cdfe3bee1b8ed854d519811e953ca0e4a7 /libs/project
parentc3f80f40f9e9b7bc3a57c3ed774dfdc1f46a8196 (diff)
downloadlibrebootfr-85934d62d767a484fa560066b6edb69a18145690.tar.gz
librebootfr-85934d62d767a484fa560066b6edb69a18145690.zip
Replace usage of the '[' Bash builtin with '[['
There's no benefit to using the POSIX-style '[' test builtin considering its '-a' and '-o' operators are unused in the Libreboot build system. Plus, '[[' is safer with respect to any containing file redirections (for example). Prior, both '[' and '[[' were used throughout the codebase--a disparity in usage which this change aims to eliminate.
Diffstat (limited to 'libs/project')
-rwxr-xr-xlibs/project96
1 files changed, 48 insertions, 48 deletions
diff --git a/libs/project b/libs/project
index 524e6222..72bd647a 100755
--- a/libs/project
+++ b/libs/project
@@ -39,7 +39,7 @@ project_helper_include() {
local project_path=$( project_path "$project" )
local include="$project_path/$project-helper"
- if [ -f "$include" ]
+ if [[ -f "$include" ]]
then
source "$include"
fi
@@ -254,7 +254,7 @@ project_sources_path() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
path="$path-$argument"
fi
@@ -267,7 +267,7 @@ project_sources_path() {
sources_path=$path
done
- if ! [ -z "$sources_path" ]
+ if ! [[ -z "$sources_path" ]]
then
printf '%s\n' "$sources_path"
return
@@ -287,7 +287,7 @@ project_sources_path() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
path="$path/$argument"
fi
@@ -300,7 +300,7 @@ project_sources_path() {
sources_path=$path
done
- if ! [ -z "$sources_path" ]
+ if ! [[ -z "$sources_path" ]]
then
printf '%s\n' "$sources_path"
return
@@ -323,7 +323,7 @@ project_sources_directory_filled_error() {
local sources_path=$( project_sources_path "$project" "$@" )
- if ! [ -z "$sources_path" ]
+ if ! [[ -z "$sources_path" ]]
then
printf 1>&2 '%s\n' "Sources directory for project $project (with ${arguments:-no argument}) already exists"
return 1
@@ -339,7 +339,7 @@ project_sources_directory_missing_empty_error() {
local sources_path=$( project_sources_path "$project" "$@" )
- if [ -z "$sources_path" ]
+ if [[ -z "$sources_path" ]]
then
printf 1>&2 '%s\n' "Sources directory for project $project (with ${arguments:-no argument}) missing or empty"
return 1
@@ -358,14 +358,14 @@ project_sources_archive() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
path="$path-$argument"
fi
local archive="$path.$ARCHIVE"
- if ! [ -f "$archive" ]
+ if ! [[ -f "$archive" ]]
then
continue
fi
@@ -373,7 +373,7 @@ project_sources_archive() {
sources_archive=$archive
done
- if ! [ -z "$sources_archive" ]
+ if ! [[ -z "$sources_archive" ]]
then
printf '%s\n' "$sources_archive"
fi
@@ -403,7 +403,7 @@ project_sources_archive_update() {
local archive=$( project_sources_archive "$project" "$@" )
local destination=$( dirname "$archive" )
- if [ -d "$sources_path" ]
+ if [[ -d "$sources_path" ]]
then
rm -rf "$sources_path"
fi
@@ -420,7 +420,7 @@ project_sources_archive_missing_error() {
local arguments="$*"
local archive=$( project_sources_archive "$project" "$@" )
- if [ -z "$archive" ] || ! [ -f "$archive" ]
+ if [[ -z "$archive" ]] || ! [[ -f "$archive" ]]
then
printf 1>&2 '%s\n' "Missing sources archive for $project (with ${arguments:-no argument})"
return 1
@@ -434,7 +434,7 @@ project_sources_archive_missing_check() {
shift
local archive=$( project_sources_archive "$project" "$@" )
- if [ -z "$archive" ] || ! [ -f "$archive" ]
+ if [[ -z "$archive" ]] || ! [[ -f "$archive" ]]
then
return 0
else
@@ -474,9 +474,9 @@ project_blobs_path() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
- if [ -z "$path" ]
+ if [[ -z "$path" ]]
then
path="$argument"
else
@@ -486,7 +486,7 @@ project_blobs_path() {
local blobs_path="$configs_path/$path/$BLOBS"
- if [ -f "$blobs_path" ]
+ if [[ -f "$blobs_path" ]]
then
printf '%s\n' "$blobs_path"
return
@@ -507,9 +507,9 @@ project_blobs_ignore_path() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
- if [ -z "$path" ]
+ if [[ -z "$path" ]]
then
path="$argument"
else
@@ -519,7 +519,7 @@ project_blobs_ignore_path() {
blobs_ignore_path="$configs_path/$path/$BLOBS_IGNORE"
- if [ -f "$blobs_ignore_path" ]
+ if [[ -f "$blobs_ignore_path" ]]
then
printf '%s\n' "$blobs_ignore_path"
return
@@ -542,7 +542,7 @@ project_arguments_targets() {
targets_path="$targets_path/$TARGETS"
- if [ -f "$targets_path" ]
+ if [[ -f "$targets_path" ]]
then
cat "$targets_path"
fi
@@ -746,9 +746,9 @@ project_build_check() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
- if [ -z "$path" ]
+ if [[ -z "$path" ]]
then
path="$argument"
else
@@ -758,7 +758,7 @@ project_build_check() {
configs_install_path="$project_path/$CONFIGS/$path/$INSTALL"
- if ! [ -f "$configs_install_path" ]
+ if ! [[ -f "$configs_install_path" ]]
then
continue
fi
@@ -771,7 +771,7 @@ project_build_check() {
# Source may contain a wildcard.
path_wildcard_expand "$source_path" | while read -r source_file_path
do
- if ! [ -f "$source_file_path" ] && ! [ -d "$source_file_path" ]
+ if ! [[ -f "$source_file_path" ]] && ! [[ -d "$source_file_path" ]]
then
false
fi
@@ -826,9 +826,9 @@ project_install() {
# Install built files first.
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
- if [ -z "$path" ]
+ if [[ -z "$path" ]]
then
path="$argument"
else
@@ -838,7 +838,7 @@ project_install() {
configs_install_path="$project_path/$CONFIGS/$path/$INSTALL"
- if ! [ -f "$configs_install_path" ]
+ if ! [[ -f "$configs_install_path" ]]
then
continue
fi
@@ -869,9 +869,9 @@ project_install() {
# Install install files then.
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
- if [ -z "$path" ]
+ if [[ -z "$path" ]]
then
path="$argument"
else
@@ -881,7 +881,7 @@ project_install() {
install_install_path="$project_path/$INSTALL/$path/$INSTALL"
- if ! [ -f "$install_install_path" ]
+ if ! [[ -f "$install_install_path" ]]
then
continue
fi
@@ -920,9 +920,9 @@ project_install_check() {
# Install built files first.
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
- if [ -z "$path" ]
+ if [[ -z "$path" ]]
then
path="$argument"
else
@@ -932,7 +932,7 @@ project_install_check() {
configs_install_path="$project_path/$CONFIGS/$path/$INSTALL"
- if ! [ -f "$configs_install_path" ]
+ if ! [[ -f "$configs_install_path" ]]
then
continue
fi
@@ -944,7 +944,7 @@ project_install_check() {
destination=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\\2/g" )
destination_path="$install_path/$destination"
- if ! [ -f "$destination_path" ] && ! [ -d "$destination_path" ]
+ if ! [[ -f "$destination_path" ]] && ! [[ -d "$destination_path" ]]
then
false
fi
@@ -956,9 +956,9 @@ project_install_check() {
# Install install files then.
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
- if [ -z "$path" ]
+ if [[ -z "$path" ]]
then
path="$argument"
else
@@ -968,7 +968,7 @@ project_install_check() {
install_install_path="$project_path/$INSTALL/$path/$INSTALL"
- if ! [ -f "$install_install_path" ]
+ if ! [[ -f "$install_install_path" ]]
then
continue
fi
@@ -978,7 +978,7 @@ project_install_check() {
destination=$( printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\\2/g" )
destination_path="$install_path/$destination"
- if ! [ -f "$destination_path" ] && ! [ -d "$destination_path" ]
+ if ! [[ -f "$destination_path" ]] && ! [[ -d "$destination_path" ]]
then
false
fi
@@ -1025,7 +1025,7 @@ project_release_path() {
local release_path="$root/$RELEASE/$prefix"
# Special care for tools and systems, that depend on the host arch.
- if [ "$prefix" = "$SYSTEMS" ] || [ "$prefix" = "$TOOLS" ]
+ if [[ "$prefix" = "$SYSTEMS" ]] || [[ "$prefix" = "$TOOLS" ]]
then
local machine=$( uname -m )
@@ -1088,7 +1088,7 @@ project_release_sources_archive_path() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
path="$path-$argument"
fi
@@ -1103,7 +1103,7 @@ project_release_sources_archive_path() {
release_path=$path
done
- if ! [ -z "$release_path" ]
+ if ! [[ -z "$release_path" ]]
then
local archive_path="$root/$RELEASE/$SOURCES/$project/$release_path.$ARCHIVE"
@@ -1131,7 +1131,7 @@ project_release_sources_archive_exists_check() {
shift
local archive_path=$( project_release_sources_archive_path "$project" "$@" )
- if [ -z "$archive_path" ] || ! [ -f "$archive_path" ]
+ if [[ -z "$archive_path" ]] || ! [[ -f "$archive_path" ]]
then
return 1
else
@@ -1399,12 +1399,12 @@ project_file_path() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
path="$path/$argument"
fi
- if ! [ -f "$path/$file" ]
+ if ! [[ -f "$path/$file" ]]
then
continue
fi
@@ -1412,7 +1412,7 @@ project_file_path() {
file_path="$path/$file"
done
- if [ -z "$file_path" ]
+ if [[ -z "$file_path" ]]
then
return 1
fi
@@ -1429,7 +1429,7 @@ project_file_test() {
project_file_contents() {
local file_path=$( project_file_path "$@" )
- if [ -f "$file_path" ]
+ if [[ -f "$file_path" ]]
then
cat "$file_path"
fi
@@ -1450,14 +1450,14 @@ project_file_contents_herit() {
for argument in "" "$@"
do
- if ! [ -z "$argument" ]
+ if ! [[ -z "$argument" ]]
then
path="$path/$argument"
fi
file_path="$path/$file"
- if ! [ -f "$file_path" ]
+ if ! [[ -f "$file_path" ]]
then
continue
fi