Use this script in makefiles where we used custom shell code before.
$(MAKE) -C $(@:subdir-%=%) $(MAKECMDGOALS)
-UNCRUSTIFY_FILES = $(shell git ls-files|git check-attr --stdin uncrustify|awk -F: '/uncrustify: set$$/ {print $$1}')
+UNCRUSTIFY_FILES = $(shell etc/git-ls-files-attr uncrustify)
UNCRUSTIFY_CFG = etc/uncrustify.cfg
define UNCRUSTIFY_ALL
$(foreach i,$(UNCRUSTIFY_FILES),git show HEAD:$i | uncrustify -c $(UNCRUSTIFY_CFG) -o $i
# `make release` can ignore files without certain git attribute
RELEASE_IGNORE_FILES_CMD = $(strip $(if $(RELEASE_ATTR),\
- git ls-files | git check-attr --stdin $(RELEASE_ATTR)|awk -F: '!/$(RELEASE_ATTR): set$$/ {print $$1}',\
+ etc/git-ls-files-attr --not $(RELEASE_ATTR),\
$(if $(filter RELEASE_ATTR,$(.VARIABLES)),,$(error Please specify RELEASE_ATTR variable (it can be empty)))))
# Usage: $(call release_rules,<release_prefix>)
--- /dev/null
+#!/bin/sh
+
+usage() { echo >&2 "Usage: $0 [ --not ] [ --set | --unset | --unspecified ] <attr> <ls-files args>..."; }
+
+state=set
+
+if test $1 = "--not"; then
+ not=true
+ shift
+else
+ not=false
+fi
+
+
+case $1 in
+ --set) state=set; shift;;
+ --unspecified) state=unspecified; shift;;
+ --unset) state=unset; shift;;
+ -*) usage; exit 1;;
+esac
+
+if test -z "$1"; then usage; exit 1; fi
+
+attr=$1
+shift
+
+git ls-files "$@" | git check-attr --stdin $attr | if $not; then
+ awk -F': ' -v state=$state '{ if ($3 != state) print $1 }'
+else
+ awk -F': ' -v state=$state '{ if ($3 == state) print $1 }'
+fi