mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-04-27 19:23:08 +00:00
tools: Fix shellcheck issues in apply_patches.sh
Fix shellcheck warnings and notes identified by running shellcheck --severity=style. Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
This commit is contained in:
@@ -8,10 +8,11 @@
|
||||
#
|
||||
set -e
|
||||
|
||||
script_dir="$(realpath $(dirname $0))"
|
||||
# shellcheck disable=SC2034
|
||||
script_dir="$(realpath "$(dirname "$0")")"
|
||||
patches_dir="$1"
|
||||
|
||||
if [ -z "$patches_dir" ]; then
|
||||
if [[ -z "${patches_dir}" ]]; then
|
||||
cat <<-EOF
|
||||
Apply patches to the sources at the current directory.
|
||||
|
||||
@@ -34,13 +35,13 @@ if [ -z "$patches_dir" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "INFO: Apply patches from $patches_dir"
|
||||
if [ -d "$patches_dir" ]; then
|
||||
patches=($(find "$patches_dir" -maxdepth 1 -name '*.patch'|sort -t- -k1,1n))
|
||||
echo "INFO: Apply patches from ${patches_dir}"
|
||||
if [[ -d "${patches_dir}" ]]; then
|
||||
mapfile -t patches < <(find "${patches_dir}" -maxdepth 1 -name '*.patch'|sort -t- -k1,1n)
|
||||
echo "INFO: Found ${#patches[@]} patches"
|
||||
for patch in "${patches[@]}"; do
|
||||
echo "INFO: Apply $patch"
|
||||
patch -p1 < "$patch" || \
|
||||
echo "INFO: Apply ${patch}"
|
||||
patch -p1 < "${patch}" || \
|
||||
{ echo >&2 "ERROR: Not applied. Exiting..."; exit 1; }
|
||||
done
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user