3 # A Nautilus extension which offers configurable context menu actions.
5 # Copyright (C) 2005 The GNOME Foundation
6 # Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
7 # Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
9 # This Program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # This Program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public
20 # License along with this Library; see the file COPYING. If not,
21 # write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307, USA.
25 # Frederic Ruaudel <grumz@grumz.net>
26 # Rodrigo Moya <rodrigo@gnome-db.org>
27 # Pierre Wieser <pwieser@trychlos.org>
28 # ... and many others (see AUTHORS)
30 errs
=0 # will be the exit code of the script
31 my_cmd
="${0}" # e.g. "./make-ks.sh"
32 my_parms
="$*" # e.g. "-host toaster"
33 my_cmdline
="${my_cmd} ${my_parms}"
34 me
="${my_cmd##*/}" # e.g. "make-ks.sh"
35 # used in msg and msgerr functions
36 my_tmproot
="/tmp/$(echo ${me} | sed 's?\..*$??').$$"
37 # e.g. "/tmp/make-ks.1978"
39 # These three functions must be defined using the name() syntax in order
40 # to share traps with the caller process (cf. man (1) ksh).
45 [ "${opt_verbose}" = "yes" -o ${errs} -gt 0 ] && msg "exiting with code ${errs}"
51 msg
"quitting on keyboard interrupt"
58 [ "${opt_verbose}" = "yes" ] && msg
"quitting on TERM signal"
62 # setup the different trap functions
67 function clear_tmpfiles
69 \rm
-f ${my_tmproot}.
*
75 [ $# -ge 2 ] && _eol
="${2}"
76 printf "[%s] %s${_eol}" ${me} "${1}"
82 msg
"error: ${1}" 1>&2
88 msg
"warning: ${1}" 1>&2
96 This script checks for header files consistency and completeness.
97 It ensures that each header files itself includes the set of prequisite
98 header files so that the tested header is auto-sufficent.
100 Usage: ${my_cmd} [options]
101 --[no]help print this message, and exit [${opt_help_def}]
102 --[no]version print script version, and exit [${opt_version_def}]
103 --[no]dummy dummy execution [${opt_dummy_def}]
104 --[no]verbose runs verbosely [${opt_verbose_def}]"
109 pck_name
=$
(grep '^PACKAGE_NAME' Makefile
2>/dev
/null |
awk '{ print $3 }')
110 pck_version
=$
(grep '^PACKAGE_VERSION' Makefile
2>/dev
/null |
awk '{ print $3 }')
112 ${pck_name} v ${pck_version}
113 Copyright (C) 2011 Pierre Wieser."
116 # initialize common command-line options
127 # a first loop over command line arguments to detect verbose mode
130 # break when all arguments have been read
137 # get and try to interpret the next argument
141 # make all options have two hyphens
142 _orig_option
=${_option}
151 # now process options and their argument
153 --noverb |
--noverbo |
--noverbos |
--noverbose)
156 --verb |
--verbo |
--verbos |
--verbose)
162 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_verbose to 'yes'"
164 # we have scanned all command-line arguments in order to detect an
165 # opt_verbose option;
166 # reset now arguments so that they can be scanned again in main script
169 # interpreting command-line arguments
171 opt_potfile_def
="po/POTFILES.in"
173 # loop over command line arguments
177 # break when all arguments have been read
184 # get and try to interpret the next argument
188 # make all options have two hyphens
189 orig_option
=${option}
198 # split and extract argument for options that take one
201 optarg
=$
(echo ${option} |
sed -e 's/^[^=]*=//')
202 option
=$
(echo ${option} |
sed 's/=.*//')
204 # these options take a mandatory argument
205 # since, we didn't find it in 'option', so it should be
206 # next word in the command line
207 #--p | -po | -pot | -potf | -potfi | -potfil | -potfile)
213 # now process options and their argument
215 --d |
--du |
--dum |
--dumm |
--dummy)
216 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_dummy to 'yes'"
219 --h |
--he |
--hel |
--help)
220 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_help to 'yes'"
223 --nod |
--nodu |
--nodum |
--nodumm |
--nodummy)
224 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_dummy to 'no'"
227 --noh |
--nohe |
--nohel |
--nohelp)
228 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_help to 'no'"
231 --noverb |
--noverbo |
--noverbos |
--noverbose)
233 --novers |
--noversi |
--noversio |
--noversion)
234 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_version to 'no'"
237 --verb |
--verbo |
--verbos |
--verbose)
239 --vers |
--versi |
--versio |
--version)
240 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_version to 'yes'"
244 msgerr
"unrecognized option: '${orig_option}'"
247 # positional parameters
250 #if [ ${pos} -eq 1 ]; then
251 # [ "${opt_verbose}" = "yes" ] && msg "setting opt_output to '${option}'"
252 # opt_output=${option}
254 msgerr
"unexpected positional parameter #${pos}: '${option}'"
261 # set option defaults
262 # does not work with /bin/sh ??
263 #set | grep -e '^opt_' | cut -d= -f1 | while read _name; do
264 # if [ "$(echo ${_name} | sed 's/.*\(_def\)/\1/')" != "_def" ]; then
265 # _value="$(eval echo "$"${_name})"
266 # if [ "${_value}" = "" ]; then
267 # eval ${_name}="$(eval echo "$"${_name}_def)"
272 opt_help
=${opt_help:-${opt_help_def}}
273 opt_dummy
=${opt_dummy:-${opt_dummy_def}}
274 opt_verbose
=${opt_verbose:-${opt_verbose_def}}
275 opt_version
=${opt_version:-${opt_version_def}}
277 if [ "${opt_help}" = "yes" -o ${nbopt} -eq 0 ]; then
283 if [ "${opt_version}" = "yes" ]; then
289 if [ "$(basename $(pwd))" != "nautilus-actions" ]; then
290 msgerr
"current directory is $(pwd)"
291 msg
"you should change to nautilus-actions/"
295 if [ ${errs} -gt 0 ]; then
296 msg
"${errs} error(s) have been detected"
297 msg
"try '${my_cmd} --help' for usage"
301 # ---------------------------------------------------------------------
304 for f
in $
(git ls-files src |
grep '\.h$' |
grep -v '^src/test'); do
305 msg
"checking for $f..." " "
306 tmpc
=tools
/check-header.c
309 int main
( int argc
, char
**argv
){ return( 0 ); }
311 make -C tools check-header
1>/dev
/null
2>&1 && tools
/check-header
1>/dev
/null
2>&1
312 [ $?
-eq 0 ] && echo "OK" ||
{ echo "NOT OK"; let errs
+=1; }