1515
1616shopt -s nullglob
1717
18- spec_count=` ls -1 * spec 2> /dev/null | wc -l`
18+ spec_count=$( ls -1 * spec 2> /dev/null | wc -l)
1919if [[ $spec_count != 1 ]]; then
2020 echo " Can't detect spec file to work with - current folder either contains no spec files or contains several spec files."
2121 exit
@@ -38,7 +38,7 @@ if [[ $target_patch == '-h' || $target_patch == '--help' ]]; then
3838fi
3939
4040# Remember number of patch files in current dir
41- patch_count=` ls -1 * patch 2> /dev/null | wc -l`
41+ patch_count=$( ls -1 * patch 2> /dev/null | wc -l)
4242
4343if [[ " ${target_patch} " == " " ]]; then
4444 # if no patch is provided as script argument and there is only a single patch in the folder,
@@ -51,7 +51,7 @@ if [[ "${target_patch}" == "" ]]; then
5151 fi
5252 exit 1
5353 else
54- target_patch=` ls -1 * patch`
54+ target_patch=$( ls -1 * patch)
5555 echo " No patch specified as an argument, processing ${target_patch} "
5656 fi
5757fi
@@ -63,16 +63,16 @@ if [[ $? == 0 ]]; then
6363 patch_cmd=" patch -p1 --force"
6464elif [[ $patch_count == 1 ]]; then
6565 # only one patch and no %apply_patches, so we can expect the only %patch command in the spec
66- patch_cmd=` grep ' ^%patch' * spec | cut -f1,2 -d- | sed ' s/^%patch[[:digit:]]*/patch --force /' `
66+ patch_cmd=$( grep ' ^%patch' * spec | cut -f1,2 -d- | sed ' s/^%patch[[:digit:]]*/patch --force /' )
6767else
6868 # grep for Patch: record in spec corresponding to our patch
6969 # drop name from the beginning of the patch name,
7070 # since one can use %name or %{name} in patch name in spec
71- project=` basename " $PWD " `
72- patch_num=` grep " ^Patch.*${target_patch/ $project / } " * spec | sed ' s/^Patch\([[:digit:]]*\).*$/\1/' `
71+ project=$( basename " $PWD " )
72+ patch_num=$( grep " ^Patch.*${target_patch/ $project / } " * spec | sed ' s/^Patch\([[:digit:]]*\).*$/\1/' )
7373
7474 # now grep for necessary %patch command
75- patch_cmd=` grep " \%patch${patch_num} [[:space:]]\|\%patch${patch_num} \$ " * spec | cut -f1,2 -d- | sed ' s/^\%patch[[:digit:]]*/patch --force /' `
75+ patch_cmd=$( grep " \%patch${patch_num} [[:space:]]\|\%patch${patch_num} \$ " * spec | cut -f1,2 -d- | sed ' s/^\%patch[[:digit:]]*/patch --force /' )
7676fi
7777
7878rm -rf rediff_patch
128128# Let's check how many folders exist in the current one after tarball unpacking
129129# We support only the situation when we have a single folder (except .git)
130130# which will be subjected to patching then
131- count=` ls -l | grep -v .git | grep ' ^d' 2> /dev/null | wc -l`
131+ count=$( ls -l | grep -v .git | grep ' ^d' 2> /dev/null | wc -l)
132132if [[ $count != 1 ]]; then
133133 if [[ $count == 0 ]]; then
134134 echo " No folders, something went wrong with unpacking of tarball"
@@ -140,7 +140,7 @@ if [[ $count != 1 ]]; then
140140fi
141141
142142# Create folder backup and try to apply the patch
143- folder=` ls -l | grep ' ^d' | rev | cut -f1 -d\ | rev`
143+ folder=$( ls -l | grep ' ^d' | rev | cut -f1 -d\ | rev)
144144cp -r $folder ${folder} .orig
145145cp ../$target_patch $folder
146146
0 commit comments