summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLed <ledest@gmail.com>2014-12-27 21:12:48 (GMT)
committerLed <ledest@gmail.com>2015-01-11 18:24:15 (GMT)
commitb50cde605a89f08ddb5ef8c5766724bd81fd5a5c (patch)
tree398ce0fc12d1011015a6b1f7dfa71271075af3f0
parent767aa9befcf74d6b70f37539ac3a442370a9421b (diff)
Fix bashisms in patch-rework.sh script
This script has a '#!/bin/sh' shabang and might be running on a POSIX shell. So replace bash-specific constructions (pushd/popd, for((...)), read with '-u' option) to POSIX-shell equivalents. Signed-off-by: Led ledest@gmail.com
-rwxr-xr-xscripts/patch-rework.sh14
1 files changed, 8 insertions, 6 deletions
diff --git a/scripts/patch-rework.sh b/scripts/patch-rework.sh
index 3d97795..2809348 100755
--- a/scripts/patch-rework.sh
+++ b/scripts/patch-rework.sh
@@ -67,10 +67,10 @@ do_check_files_at_depth() {
exec 6<&0
exec 7<"${flist}"
- while read -u7 f; do
+ while read f; do
f="$( echo "${f}" |sed -r -e "s:^([^/]+/){${depth}}::;" )"
[ -f "${f}" ] || ret=1
- done
+ done </dev/fd/7
exec 7<&-
exec <&6
@@ -106,16 +106,18 @@ $1=="+++" && mark==1 { nextfile; }
>"diffstat.orig"
printf " done\n"
- pushd "${base}" >/dev/null 2>&1
+ cd "${base}"
# Check all files exist, up to depth 3
printf " checking depth:"
- for((d=0;d<4;d++)); do
+ d=0
+ while [ $d -lt 4 ]; do
printf " ${d}"
if do_check_files_at_depth "../diffstat.orig" ${d}; then
printf " ok, using depth '${d}'\n"
break
fi
+ d=$((d + 1))
done
if [ ${d} -ge 4 ]; then
printf "\n"
@@ -133,7 +135,7 @@ $1=="+++" && mark==1 { nextfile; }
printf " applying patch..."
if ! patch -g0 -F1 -f -p${d} <"${p}" >"../patch.out" 2>&1; then
printf " ERROR\n\n"
- popd >/dev/null 2>&1
+ cd - >/dev/null
printf "There was an error while applying:\n --> ${p} <--\n"
printf "'${base}' was restored to the state it was prior to applying this faulty patch.\n"
printf "Here's the 'patch' command, and its output:\n"
@@ -149,7 +151,7 @@ $1=="+++" && mark==1 { nextfile; }
find . -type f -name '*.orig' -exec rm -f {} +
printf " done\n"
- popd >/dev/null 2>&1
+ cd - >/dev/null
printf " re-diffing the patch..."
printf "%s\n\n" "${comment}" >"${dst}/${pname}"