From: Colin Watson Date: Thu, 23 Oct 2003 16:36:01 +0000 (+0000) Subject: grep-nonposix: New script to check for obvious POSIX 1003.1-2001 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=commitdiff_plain;h=cdeb5753d5b7f21b964c5fbc0401085db83182a5 grep-nonposix: New script to check for obvious POSIX 1003.1-2001 non-conformance, modified from a version by Paul Eggert. See: http://lists.debian.org/debian-glibc/2003/debian-glibc-200308/msg00120.html --- diff --git a/grep-nonposix b/grep-nonposix new file mode 100755 index 0000000..a964cb0 --- /dev/null +++ b/grep-nonposix @@ -0,0 +1,33 @@ +#! /bin/sh + +LC_ALL=C +export LC_ALL +IFS=' +' + +pattern='(expand|head|fold|split|tail|uniq|unexpand|nice|diff)\>.*[ ]-[a-zA-Z]*[0-9]|(sort|tail|uniq)\>.*[ ]\+[0-9]+[a-zA-Z_]*|sort\>.*[ ]-o' + +case $1 in +--help) + exec echo "$0: usage: $0 [OPTION]... [FILE]... +Grep for instances of possible POSIX-conformance problems in the FILEs. +Options: + -s Check strictly, even for things that aren't likely to be real problems. +The FILEs can be directories, in which case the greps are recursive, +though ChangeLogs, backup files, and version-control histories are bypassed. +The default FILE is '-', which stands for the standard input.";; + +-s) + pattern=$pattern'|[ef]grep\>|(\[|test\>).*[ ]-[ao]\>' + shift;; +esac + +pattern='\<('$pattern')' + +case $# in +0) exec grep -E -n "$pattern";; +*) find "${@-.}" -type f \ + ! -name '*~' ! -name 'ChangeLog*' ! -name '*,v' \ + -print \ + | sort | xargs grep -E -n "$pattern";; +esac