r67867 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67866‎ | r67867 | r67868 >
Date:21:10, 11 June 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Document what does this bunch of make, regex and sed code.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/Makefile (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/Makefile
@@ -131,6 +131,13 @@
132132 WikiEditor/WikiEditor.hooks.php: $(WIKIEDITOR_HOOKS)
133133 Vector/Vector.hooks.php: $(VECTOR_HOOKS)
134134
 135+# - Metarule for the above three files -
 136+# For each modified file (make $?):
 137+# Set $basefile to the path relative to the file being modified (ie. strip the folder).
 138+# Use sed to replace the line for that file with '+1' appended to the version.
 139+# Note that $${basefile//\//\\/} expands in the shell to $basefile with all slashes escaped.
 140+# End for
 141+# For each group of summing numbers inside the target file, use bc to calculate the sum and replace with sed.
135142 %.hooks.php: $(WIKIEDITOR_HOOKS)
136143 for file in $?; do basefile="$${file#$(shell echo $* | sed "s/\([^\/]*\/\).*/\\1/")}"; sed -i -e "s/\(.*'src' => '$${basefile//\//\\/}', 'version' => \)\([0-9+]*\)\(.*\)/\\1\\2+1\\3/" $@; \
137144 for i in $$(grep --only-matching -P " ([0-9]+(\+[0-9]))+ " $@); do sed -i -e "s/ $$i / $$(bc <<< $$i) /" $@; done; done

Follow-up revisions

RevisionCommit summaryAuthorDate
r67961Remove bc dependency using the shell Arithmetic expansion, per Roan CR in r67867platonides20:58, 13 June 2010

Comments

#Comment by Catrope (talk | contribs)   20:49, 12 June 2010

Do you need bc? Can't you use bash's built-in basic math functionality?

#Comment by Platonides (talk | contribs)   20:58, 13 June 2010

Good point. I thought it was a bash feature, but it turns out to be POSIX.

Changed in r67961.

Status & tagging log