summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2013-01-11 11:13:12 +0100
committerGravatar Tom Willemsen2013-01-11 11:13:12 +0100
commitfc57f091501071cf5fadd327480aa67338cac88e (patch)
treea2dfb1221e78325a7fa8eabf98c8516ea41a464b
parentcef98d73fcf6a1dcae0a4ce094581340249d96a7 (diff)
downloadorgweb-fc57f091501071cf5fadd327480aa67338cac88e.tar.gz
orgweb-fc57f091501071cf5fadd327480aa67338cac88e.zip
Add "check-php-syntax" snippet
-rw-r--r--site/index.org1
-rw-r--r--site/snippets/check-php-syntax.org32
2 files changed, 33 insertions, 0 deletions
diff --git a/site/index.org b/site/index.org
index 0389f72..38dd08e 100644
--- a/site/index.org
+++ b/site/index.org
@@ -37,6 +37,7 @@
* Snippets
+ [[file:snippets/check-php-syntax.org][check-php-syntax]]
[[file:snippets/etcgit.org][etcgit]]
[[file:snippets/euler-problem-1.org][euler-problem-1]]
[[file:snippets/org-export.org][org-export]]
diff --git a/site/snippets/check-php-syntax.org b/site/snippets/check-php-syntax.org
new file mode 100644
index 0000000..b213113
--- /dev/null
+++ b/site/snippets/check-php-syntax.org
@@ -0,0 +1,32 @@
+#+TITLE: check-php-syntax
+#+OPTIONS: toc:nil
+
+* check-php-syntax
+
+ A ~pre-commit~ script for git that checks if all php source files
+ have proper syntax. This catches far from all mistakes (as most are
+ not syntax related, of course), but it helps sometimes.
+
+ #+BEGIN_SRC sh :tangle yes
+ #!/bin/zsh
+
+ result=0
+
+ cd $PWD/src
+ for php in **/*.php
+ do
+ message=$(php -l $php)
+ if [ $? -ne 0 ]
+ then
+ echo "$message"
+ result=1
+ fi
+ done
+
+ if [ $result -eq 0 ]
+ then
+ echo "All checked out"
+ fi
+
+ exit $result
+ #+END_SRC