From 9949e2e4eb57e639a6a4673cccdaf62d9acbb7a1 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Jul 10 2018 00:00:37 +0000 Subject: Handle another defattr format. Pull the pattern out to a variable and adjust it to handle the three-argument form of %defattr. --- diff --git a/find-needless-defattr b/find-needless-defattr index 3a25432..c17f6ef 100755 --- a/find-needless-defattr +++ b/find-needless-defattr @@ -6,6 +6,8 @@ autoload zsh/util exename=${0:t} +PATTERN='%defattr\s*\((-|0?644)\s*,\s*root,\s*root(,\s*(-|0?755)?)?\)' + usage () { cat << END $exename [options] DIR @@ -32,7 +34,6 @@ parse_args () { (echo "Error: A directory must be specified."; echo; usage) >&2 exit 1 fi - } main () { @@ -41,11 +42,11 @@ main () { specs=(${(f)"$(find $specdir -name \*.spec|sort)"}) if (( listonly )); then - grep -A1 '^%files' $specs | grep -B1 -P '%defattr\s*\((-|0?644)\s*,\s*root,\s*root,\s*(-|0?755)?\)' + grep -A1 '^%files' $specs | grep -B1 -P $PATTERN exit 0 fi - badspecs=(${(f)"$(grep -A1 '^%files' $specs | grep -P '%defattr\s*\((-|0?644)\s*,\s*root,\s*root,\s*(-|0?755)?\)')"}) + badspecs=(${(f)"$(grep -A1 '^%files' $specs | grep -P $PATTERN)"}) echo ${(F)${(u)${badspecs##*/}%.spec-*}} }