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/common | |
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/common')
-rwxr-xr-x | libs/common | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/libs/common b/libs/common index fd001a5d..43fe3b08 100755 --- a/libs/common +++ b/libs/common @@ -130,7 +130,7 @@ path_wildcard_expand() { local path=$@ # Evaluation fails with unescaped whitespaces. - path=$( printf '%s\n' "$path" | sed "s/ /\\\ /g" ) + path=$(printf '%s\n' "$path" | sed "s/ /\\\ /g") eval "arguments_list "$path"" } @@ -139,8 +139,8 @@ file_checksum_create() { local path=$1 local checksum_path="$path.$CHECKSUM" - local name=$( basename "$path" ) - local directory_path=$( dirname "$path" ) + local name=$(basename "$path") + local directory_path=$(dirname "$path") ( cd "$directory_path" @@ -152,12 +152,12 @@ file_checksum_check() { local path=$1 local checksum_path="$path.$CHECKSUM" - local name=$( basename "$path" ) - local directory_path=$( dirname "$path" ) + local name=$(basename "$path") + local directory_path=$(dirname "$path") - if ! [ -f "$checksum_path" ] + if ! [[ -f "$checksum_path" ]] then - printf '%s\n' 'Could not verify file checksum!' >&2 + printf 1>&2 '%s\n' 'Could not verify file checksum!' return 1 fi @@ -172,7 +172,7 @@ file_signature_create() { local signature_path="$path.$DSIG" - if [ -z "$RELEASE_KEY" ] + if [[ -z "$RELEASE_KEY" ]] then return 0 fi @@ -185,9 +185,9 @@ file_signature_check() { local signature_path="$path.$DSIG" - if ! [ -f "$signature_path" ] + if ! [[ -f "$signature_path" ]] then - printf '%s\n' 'Could not verify file signature!' >&2 + printf 1>&2 '%s\n' 'Could not verify file signature!' return 1 fi @@ -217,7 +217,7 @@ file_exists_check() { directory_filled_check() { local path=$1 - if [ -z "$( ls -A "$path" 2> /dev/null )" ] + if [[ -z "$(ls -A "$path" 2> /dev/null)" ]] then return 1 else @@ -379,11 +379,11 @@ requirements() { for requirement in "$@" do - requirement_path=$( which "$requirement" || true ) + requirement_path=$(which "$requirement" || true) - if [ -z "$requirement_path" ] + if [[ -z "$requirement_path" ]] then - printf '%s\n' "Missing requirement: $requirement" >&2 + printf 1>&2 '%s\n' "Missing requirement: $requirement" exit 1 fi done @@ -396,11 +396,11 @@ requirements_root() { for requirement in "$@" do # We need to keep stdout output to show the command. - requirement_path=$( execute_root which "$requirement" || true ) + requirement_path=$(execute_root which "$requirement" || true) - if [ -z "$requirement_path" ] + if [[ -z "$requirement_path" ]] then - printf '%s\n' "Missing requirement: $requirement" >&2 + printf 1>&2 '%s\n' "Missing requirement: $requirement" exit 1 fi done @@ -414,7 +414,7 @@ arguments_concat() { for argument in "$@" do - if ! [ -z "$concat" ] + if [[ -n "$concat" ]] then concat="$concat""$delimiter""$argument" else @@ -426,18 +426,18 @@ arguments_concat() { } execute_root() { - local sudo=$( which sudo 2> /dev/null || true ) + local sudo=$(which sudo 2> /dev/null || true) local arguments - printf '%s' 'Running command as root: ' >&2 - printf '%b\n' "$*" >&2 + printf 1>&2 '%s' 'Running command as root: ' + printf 1>&2 '%b\n' "$*" - if ! [ -z "$sudo" ] + if [[ -n "$sudo" ]] then sudo "$@" else # Quote arguments for eval through su. - arguments=$( printf '%q ' "$@" ) + arguments=$(printf '%q ' "$@") su -c "$arguments" fi } |