<p class="wp-block-paragraph">In a world where Bash shell is under attack I attach a short shell script that make me waste less time in upload/commit/test loop:</p>
<pre class="wp-block-preformatted">#! /bin/sh
LIST=`find . -name '*.php'`
for x in $LIST; do
OUTPUT=`php -l $x`
A=$?
if [ $A -ne 0 ]; then
echo "ERROR ON " $x "with " $OUTPUT;
fi
done
</pre>
<p class="wp-block-paragraph">simple enough as running</p>
<p class="wp-block-paragraph">./php-lint.sh</p>
<p class="wp-block-paragraph">on a git repository, do not traverse all tree but just the changed files, and launch just before commit the script</p>
<pre class="wp-block-preformatted">#! /bin/sh
LIST=`git diff --name-only |grep 'php</pre>
<p class="wp-block-paragraph">Or add it as .git/hooks/pre-commit code:</p>
<pre class="wp-block-preformatted">#!/bin/sh
ERRORS=0
LIST=`git diff --name-only | grep 'php</pre>
<p class="wp-block-paragraph">(and use ‘git commit’ before committing changes).</p>
<p class="wp-block-paragraph">It is the simpliest statical analisys, the syntax check, but It save enough time for me</p>
<pre class="wp-block-preformatted">`
for x in $LIST; do
OUTPUT=`php -l $x`
A=$?
if [ $A -ne 0 ]; then
echo "ERROR ON " $x "with " $OUTPUT;
fi
done
</pre>
<p class="wp-block-paragraph">Or add it as .git/hooks/pre-commit code:</p>
<pre class="wp-block-preformatted"> </pre>
<p class="wp-block-paragraph">(and use ‘git commit’ before committing changes).</p>
<p class="wp-block-paragraph">It is the simpliest statical analisys, the syntax check, but It save enough time for me</p>
<pre class="wp-block-preformatted">` for x in $LIST; do OUTPUT=`php -l $x` A=$? if [ $A -ne 0 ]; then echo "ERROR ON " $x "with " $OUTPUT; ERRORS=1 fi done if [ $ERRORS -ne 0 ]; then exit 1 fi exit 0</pre>
<p class="wp-block-paragraph">(and use ‘git commit’ before committing changes).</p>
<p class="wp-block-paragraph">It is the simpliest statical analisys, the syntax check, but It save enough time for me</p>
<p class="wp-block-paragraph">` for x in $LIST; do OUTPUT=`php -l $x` A=$? if [ $A -ne 0 ]; then echo “ERROR ON ” $x “with ” $OUTPUT; fi done</p>
<p class="wp-block-paragraph">Or add it as .git/hooks/pre-commit code:</p>
<pre class="wp-block-preformatted"> </pre>
<p class="wp-block-paragraph">(and use ‘git commit’ before committing changes).</p>
<p class="wp-block-paragraph">It is the simpliest statical analisys, the syntax check, but It save enough time for me</p>
In a world where Bash shell is under attack I attach a short shell script that make me waste less time in upload/commit/test loop:
#! /bin/sh
LIST=`find . -name '*.php'`
for x in $LIST; do
OUTPUT=`php -l $x`
A=$?
if [ $A -ne 0 ]; then
echo "ERROR ON " $x "with " $OUTPUT;
fi
done
simple enough as running
./php-lint.sh
on a git repository, do not traverse all tree but just the changed files, and launch just before commit the script
#! /bin/sh
LIST=`git diff --name-only |grep 'php
Or add it as .git/hooks/pre-commit code:
#!/bin/sh
ERRORS=0
LIST=`git diff --name-only | grep 'php
(and use ‘git commit’ before committing changes).
It is the simpliest statical analisys, the syntax check, but It save enough time for me
`
for x in $LIST; do
OUTPUT=`php -l $x`
A=$?
if [ $A -ne 0 ]; then
echo "ERROR ON " $x "with " $OUTPUT;
fi
done
Or add it as .git/hooks/pre-commit code:
(and use ‘git commit’ before committing changes).
It is the simpliest statical analisys, the syntax check, but It save enough time for me
` for x in $LIST; do OUTPUT=`php -l $x` A=$? if [ $A -ne 0 ]; then echo "ERROR ON " $x "with " $OUTPUT; ERRORS=1 fi done if [ $ERRORS -ne 0 ]; then exit 1 fi exit 0
(and use ‘git commit’ before committing changes).
It is the simpliest statical analisys, the syntax check, but It save enough time for me
` for x in $LIST; do OUTPUT=`php -l $x` A=$? if [ $A -ne 0 ]; then echo “ERROR ON ” $x “with ” $OUTPUT; fi done
Or add it as .git/hooks/pre-commit code:
(and use ‘git commit’ before committing changes).
It is the simpliest statical analisys, the syntax check, but It save enough time for me