Use perl-oneliners instead of linux grep specific command options

This commit is contained in:
Jacob Langley 2017-02-03 11:44:20 -08:00
parent f2dfcfc438
commit 76576a82ea

View File

@ -58,7 +58,7 @@ check-references: $(SOURCEPATH) $(BUILD_DIR) Makefile
@echo '##################### References check ##################' @echo '##################### References check ##################'
## check references unique ## check references unique
@rm -f $(BUILD_DIR)/$(SOURCEFILE).uniq @rm -f $(BUILD_DIR)/$(SOURCEFILE).uniq
@grep -oP '(?<=<a name=")[^\"]+' $(SOURCEPATH) | sort | uniq -d > $(BUILD_DIR)/$(SOURCEFILE).uniq @cat $(SOURCEPATH) | perl -ne 'print "$$1\n" if (/<a name="([^\"]+)/)' | sort | uniq -d > $(BUILD_DIR)/$(SOURCEFILE).uniq
## check if output has data ## check if output has data
@if [ -s "build/CppCoreGuidelines.md.uniq" ]; then echo 'Found duplicate anchors:'; cat $(BUILD_DIR)/$(SOURCEFILE).uniq; false; fi @if [ -s "build/CppCoreGuidelines.md.uniq" ]; then echo 'Found duplicate anchors:'; cat $(BUILD_DIR)/$(SOURCEFILE).uniq; false; fi
@ -69,7 +69,7 @@ check-notabs: $(SOURCEPATH) $(BUILD_DIR) Makefile
# old file still might be around # old file still might be around
@rm -f $(BUILD_DIR)/CppCoreGuidelines.md.tabs @rm -f $(BUILD_DIR)/CppCoreGuidelines.md.tabs
# print file, add line numbers, remove tabs from nl tool, grep for remaining tabs, replace with stars # print file, add line numbers, remove tabs from nl tool, grep for remaining tabs, replace with stars
@cat ../CppCoreGuidelines.md | nl -ba | sed -s 's/\(^[^\t]*\)\t/\1--/g' | grep -P '\t' | sed -s 's/\t/\*\*\*\*/g' > $(BUILD_DIR)/CppCoreGuidelines.md.tabs @cat ../$(SOURCEFILE) | nl -ba | perl -pe 's/(^[^\t]*)\t/$1--/g' | perl -ne 'print if /\t/' | perl -pe 's/\t/\*\*\*\*/g' > $(BUILD_DIR)/$(SOURCEFILE).tabs
@if [ -s $(BUILD_DIR)/CppCoreGuidelines.md.tabs ]; then echo 'Warning: Tabs found:'; cat $(BUILD_DIR)/CppCoreGuidelines.md.tabs; false; fi; @if [ -s $(BUILD_DIR)/CppCoreGuidelines.md.tabs ]; then echo 'Warning: Tabs found:'; cat $(BUILD_DIR)/CppCoreGuidelines.md.tabs; false; fi;
.PHONY: check-badchars .PHONY: check-badchars
@ -79,7 +79,7 @@ check-badchars: $(SOURCEPATH) $(BUILD_DIR) Makefile
# old file still might be around # old file still might be around
@rm -f $(BUILD_DIR)/CppCoreGuidelines.md.badchars @rm -f $(BUILD_DIR)/CppCoreGuidelines.md.badchars
# print file, add line numbers, grep for bad chars # print file, add line numbers, grep for bad chars
@cat ../CppCoreGuidelines.md | nl -ba | grep -P '||”|“|¸||…|¦' > $(BUILD_DIR)/CppCoreGuidelines.md.badchars || true @cat ../$(SOURCEFILE) | nl -ba | perl -ne 'print if /||”|“|¸||…|¦/' > $(BUILD_DIR)/$(SOURCEFILE).badchars || true
@if [ -s $(BUILD_DIR)/CppCoreGuidelines.md.badchars ]; then echo 'Warning: Undesired chars (–’‘“”¸…¦) found, use straight quotes instead:'; cat $(BUILD_DIR)/CppCoreGuidelines.md.badchars; false; fi; @if [ -s $(BUILD_DIR)/CppCoreGuidelines.md.badchars ]; then echo 'Warning: Undesired chars (–’‘“”¸…¦) found, use straight quotes instead:'; cat $(BUILD_DIR)/CppCoreGuidelines.md.badchars; false; fi;