Skip to content

Instantly share code, notes, and snippets.

@apritzel
Created January 31, 2018 12:24
Show Gist options
  • Save apritzel/5277123a6038c461170bb01b3258a0a2 to your computer and use it in GitHub Desktop.
Save apritzel/5277123a6038c461170bb01b3258a0a2 to your computer and use it in GitHub Desktop.
very simple Xen coding style checker (to catch Linux copy&paste artefacts)
#!/bin/sh
grep -n '^ *'$'\t' "$1" && echo "^^^ tabs"
grep -n 'if(' "$1" && echo "^^^ no space after if"
grep -n 'if ([^ ]' "$1" && echo "^^^ no space after if ("
grep -n 'while(' "$1" && echo "^^^ no space after while"
grep -n 'while ([^ ]' "$1" && echo "^^^ no space after while ("
grep -n 'for(' "$1" && echo "^^^ no space after for"
grep -n 'for ([^ ]' "$1" && echo "^^^ no space after for ("
grep -n '[ ]*[^ ].*{$' "$1" && echo "^^^ opening bracket at the end of line"
grep -n '} *else' "$1" && echo "^^^ else on the same line as closing bracket"
grep -n 'else *{' "$1" && echo "^^^ else on the same line as opening bracket"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment