18462SApril.Chin@Sun.COM#!/usr/bin/ksh93
28462SApril.Chin@Sun.COM
38462SApril.Chin@Sun.COM#
48462SApril.Chin@Sun.COM# CDDL HEADER START
58462SApril.Chin@Sun.COM#
68462SApril.Chin@Sun.COM# The contents of this file are subject to the terms of the
78462SApril.Chin@Sun.COM# Common Development and Distribution License (the "License").
88462SApril.Chin@Sun.COM# You may not use this file except in compliance with the License.
98462SApril.Chin@Sun.COM#
108462SApril.Chin@Sun.COM# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
118462SApril.Chin@Sun.COM# or http://www.opensolaris.org/os/licensing.
128462SApril.Chin@Sun.COM# See the License for the specific language governing permissions
138462SApril.Chin@Sun.COM# and limitations under the License.
148462SApril.Chin@Sun.COM#
158462SApril.Chin@Sun.COM# When distributing Covered Code, include this CDDL HEADER in each
168462SApril.Chin@Sun.COM# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
178462SApril.Chin@Sun.COM# If applicable, add the following below this CDDL HEADER, with the
188462SApril.Chin@Sun.COM# fields enclosed by brackets "[]" replaced with your own identifying
198462SApril.Chin@Sun.COM# information: Portions Copyright [yyyy] [name of copyright owner]
208462SApril.Chin@Sun.COM#
218462SApril.Chin@Sun.COM# CDDL HEADER END
228462SApril.Chin@Sun.COM#
238462SApril.Chin@Sun.COM
248462SApril.Chin@Sun.COM#
258462SApril.Chin@Sun.COM# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
268462SApril.Chin@Sun.COM# Use is subject to license terms.
278462SApril.Chin@Sun.COM#
288462SApril.Chin@Sun.COM
298462SApril.Chin@Sun.COM#
308462SApril.Chin@Sun.COM# shlint - a simple lint wrapper around "shcomp"
318462SApril.Chin@Sun.COM#
328462SApril.Chin@Sun.COM
338462SApril.Chin@Sun.COM# Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant
348462SApril.Chin@Sun.COMexport PATH=/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin
358462SApril.Chin@Sun.COM
368462SApril.Chin@Sun.COM# Make sure all math stuff runs in the "C" locale to avoid problems
378462SApril.Chin@Sun.COM# with alternative # radix point representations (e.g. ',' instead of
388462SApril.Chin@Sun.COM# '.' in de_DE.*-locales). This needs to be set _before_ any
398462SApril.Chin@Sun.COM# floating-point constants are defined in this script).
408462SApril.Chin@Sun.COMif [[ "${LC_ALL}" != "" ]] ; then
418462SApril.Chin@Sun.COM    export \
428462SApril.Chin@Sun.COM        LC_MONETARY="${LC_ALL}" \
438462SApril.Chin@Sun.COM        LC_MESSAGES="${LC_ALL}" \
448462SApril.Chin@Sun.COM        LC_COLLATE="${LC_ALL}" \
458462SApril.Chin@Sun.COM        LC_CTYPE="${LC_ALL}"
468462SApril.Chin@Sun.COM        unset LC_ALL
478462SApril.Chin@Sun.COMfi
488462SApril.Chin@Sun.COMexport LC_NUMERIC=C
498462SApril.Chin@Sun.COM
508462SApril.Chin@Sun.COMfunction fatal_error
518462SApril.Chin@Sun.COM{
528462SApril.Chin@Sun.COM	print -u2 "${progname}: $*"
538462SApril.Chin@Sun.COM	exit 1
548462SApril.Chin@Sun.COM}
558462SApril.Chin@Sun.COM
568462SApril.Chin@Sun.COMfunction usage
578462SApril.Chin@Sun.COM{
588462SApril.Chin@Sun.COM	OPTIND=0
598462SApril.Chin@Sun.COM	getopts -a "${progname}" "${shlint_usage}" OPT '-?'
608462SApril.Chin@Sun.COM	exit 2
618462SApril.Chin@Sun.COM}
628462SApril.Chin@Sun.COM
638462SApril.Chin@Sun.COM# program start
648462SApril.Chin@Sun.COMbuiltin basename
658462SApril.Chin@Sun.COM
668462SApril.Chin@Sun.COMtypeset progname="${ basename "${0}" ; }"
678462SApril.Chin@Sun.COM
688462SApril.Chin@Sun.COMtypeset -r shlint_usage=$'+
69*10898Sroland.mainz@nrubsig.org[-?\n@(#)\$Id: shlint (Roland Mainz) 2009-03-15 \$\n]
708462SApril.Chin@Sun.COM[-author?Roland Mainz <roland.mainz@sun.com>]
718462SApril.Chin@Sun.COM[-author?Roland Mainz <roland.mainz@nrubsig.org>]
728462SApril.Chin@Sun.COM[+NAME?shlint - lint for POSIX shell scripts]
738462SApril.Chin@Sun.COM[+DESCRIPTION?\bshlint\b is a lint for POSIX shell scripts.]
748462SApril.Chin@Sun.COM[+SEE ALSO?\bshcomp\b(1), \bksh93\b(1)]
758462SApril.Chin@Sun.COM'
768462SApril.Chin@Sun.COM
778462SApril.Chin@Sun.COMwhile getopts -a "${progname}" "${shlint_usage}" OPT ; do
788462SApril.Chin@Sun.COM#	printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|"
798462SApril.Chin@Sun.COM	case ${OPT} in
808462SApril.Chin@Sun.COM		*)    usage ;;
818462SApril.Chin@Sun.COM	esac
828462SApril.Chin@Sun.COMdone
838462SApril.Chin@Sun.COMshift $((OPTIND-1))
848462SApril.Chin@Sun.COM
85*10898Sroland.mainz@nrubsig.org(( $# > 0 )) || usage
86*10898Sroland.mainz@nrubsig.org
878462SApril.Chin@Sun.COMfile="$1"
888462SApril.Chin@Sun.COM[[ ! -f "$file" ]] && fatal_error $"File ${file} not found."
898462SApril.Chin@Sun.COM[[ ! -r "$file" ]] && fatal_error $"File ${file} not readable."
908462SApril.Chin@Sun.COM
91*10898Sroland.mainz@nrubsig.orgx="$( /usr/bin/shcomp -n "${file}" /dev/null 2>&1 1>/dev/null  )"
928462SApril.Chin@Sun.COM
93*10898Sroland.mainz@nrubsig.orgprintf "%s\n" "$x"
948462SApril.Chin@Sun.COM
958462SApril.Chin@Sun.COM[[ "$x" != "" ]] && exit 1 || exit 0
968462SApril.Chin@Sun.COM# EOF.
97