[arch-projects] [devtools] [PATCH 1/3] commitpkg: Avoid redundant use of grep(1)
Lukas Fleischer
archlinux at cryptocrack.de
Tue Aug 9 16:53:43 EDT 2011
We already sourced the PKGBUILD, so no need to grep the name of the
install script and changelog file. Just use "$install" and "$changelog"
instead.
Also, use bash patterns instead of using grep(1) to check if a source
file contains the string "://".
Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
commitpkg | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/commitpkg b/commitpkg
index 9856df1..cfc2727 100755
--- a/commitpkg
+++ b/commitpkg
@@ -79,21 +79,16 @@ esac
# check if all local source files are under version control
for s in ${source[@]}; do
- echo $s | grep -Fvq '://' && \
- svn status $s | grep -q '^\?' && \
- abort "$s is not under version control"
+ if [[ $s != *://* ]] && svn status $s | grep -q '^\?'; then
+ abort "$s is not under version control"
+ fi
done
# check if changelog and install files are under version control
-for i in 'changelog' 'install'; do
- filelist=$(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
- for file in $filelist; do
- # evaluate any bash variables used
- eval file=${file}
- if svn status ${file} | grep -q '^\?'; then
- abort "${file} is not under version control"
- fi
- done
+for file in "$changelog" "$install"; do
+ if [[ -n ${file} ]] && svn status ${file} | grep -q '^\?'; then
+ abort "${file} is not under version control"
+ fi
done
# see if any limit options were passed, we'll send them to rsync
--
1.7.6
More information about the arch-projects
mailing list