Bruno Haible <bruno <at> clisp.org> writes: > > The --version support in the 'posix-modules' script predates the switch > from CVS to git. This updates it, using the code we have in gnulib-tool.
> --- 33,224 ---- > # outputs to stdout the --version message. > func_version () > { ... > ! gnulib-tool (GNU $package $date)$version Oops - some over-active copy-n-paste. > ! func_gnulib_dir () > ! { > ! case "$0" in > ! /*) self_abspathname="$0" ;; > ! */*) self_abspathname=`pwd`/"$0" ;; And this falls foul of autoconf's advice: http://www.gnu.org/software/autoconf/manual/autoconf.html#Shell-Functions | Inside a function, IRIX sh sets `$0' to the function name. Finally, this patch failed to call the new func_gnulib_dir, with this result in the selected 'sh -vx posix-modules' run: LC_ALL=C grep -h '^Gnulib module: ' "$gnulib_dir"/doc/posix-headers/* 2>/dev/null \ ... + grep -h '^Gnulib module: ' '/doc/posix-headers/*' leading to an overall result of no output. OK to check in this followup? http://repo.or.cz/w/gnulib/ericb.git?a=commitdiff;h=e85ee3d From: Eric Blake <[EMAIL PROTECTED]> Date: Fri, 26 Sep 2008 14:47:41 -0600 Subject: [PATCH] Fix previous patch, and tweak references to $0. * posix-modules: Call func_gnulib_dir before using $gnulib_dir. (func_version, func_gnulib_dir): Don't call this program gnulib-tool. (func_gnulib_dir, func_tmpdir, func_fatal_error): Avoid shell bugs with using $0 in function. * gnulib-tool (func_gnulib_dir, func_tmpdir): Likewise. (func_fatal_error): Reuse the name the user invoked us with. Signed-off-by: Eric Blake <[EMAIL PROTECTED]> --- ChangeLog | 13 ++++++++++++- gnulib-tool | 16 ++++++++-------- posix-modules | 28 +++++++++++++++++----------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4a3d3b..bda6cfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-09-26 Eric Blake <[EMAIL PROTECTED]> + + Fix previous patch, and tweak references to $0. + * posix-modules: Call func_gnulib_dir before using $gnulib_dir. + (func_version, func_gnulib_dir): Don't call this program + gnulib-tool. + (func_gnulib_dir, func_tmpdir, func_fatal_error): Avoid shell bugs + with using $0 in function. + * gnulib-tool (func_gnulib_dir, func_tmpdir): Likewise. + (func_fatal_error): Reuse the name the user invoked us with. + 2008-09-26 Bruno Haible <[EMAIL PROTECTED]> * posix-modules (cvsdatestamp, last_checkin_date, version): Remove diff --git a/gnulib-tool b/gnulib-tool index 56b185a..de7b289 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -277,9 +277,9 @@ func_exit () # - gnulib_dir absolute pathname of gnulib repository func_gnulib_dir () { - case "$0" in - /*) self_abspathname="$0" ;; - */*) self_abspathname=`pwd`/"$0" ;; + case "$progname" in + /*) self_abspathname="$progname" ;; + */*) self_abspathname=`pwd`/"$progname" ;; *) # Look in $PATH. # Iterate through the elements of $PATH. @@ -326,8 +326,8 @@ func_gnulib_dir () for d in $pathx; do IFS="$save_IFS" test -z "$d" && d=. - if test -x "$d/$0" && test ! -d "$d/$0"; then - self_abspathname="$d/$0" + if test -x "$d/$progname" && test ! -d "$d/$progname"; then + self_abspathname="$d/$progname" break fi done @@ -375,7 +375,7 @@ func_tmpdir () (umask 077 && mkdir "$tmp") } || { - echo "$0: cannot create a temporary directory in $TMPDIR" >&2 + echo "$progname: cannot create a temporary directory in $TMPDIR" >&2 func_exit 1 } } @@ -400,8 +400,8 @@ fi # outputs to stderr a fatal error message, and terminates the program. func_fatal_error () { - echo "gnulib-tool: *** $1" 1>&2 - echo "gnulib-tool: *** Stop." 1>&2 + echo "$progname: *** $1" 1>&2 + echo "$progname: *** Stop." 1>&2 func_exit 1 } diff --git a/posix-modules b/posix-modules index 2fa010b..adb887b 100755 --- a/posix-modules +++ b/posix-modules @@ -66,7 +66,7 @@ q fi year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'` echo "\ -gnulib-tool (GNU $package $date)$version +posix-modules (GNU $package $date)$version Copyright (C) $year Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. @@ -87,13 +87,13 @@ func_exit () # func_gnulib_dir # locates the directory where the gnulib repository lives # Sets variables -# - self_abspathname absolute pathname of gnulib-tool +# - self_abspathname absolute pathname of this program # - gnulib_dir absolute pathname of gnulib repository func_gnulib_dir () { - case "$0" in - /*) self_abspathname="$0" ;; - */*) self_abspathname=`pwd`/"$0" ;; + case "$progname" in + /*) self_abspathname="$progname" ;; + */*) self_abspathname=`pwd`/"$progname" ;; *) # Look in $PATH. # Iterate through the elements of $PATH. @@ -140,14 +140,14 @@ func_gnulib_dir () for d in $pathx; do IFS="$save_IFS" test -z "$d" && d=. - if test -x "$d/$0" && test ! -d "$d/$0"; then - self_abspathname="$d/$0" + if test -x "$d/$progname" && test ! -d "$d/$progname"; then + self_abspathname="$d/$progname" break fi done IFS="$save_IFS" if test -z "$self_abspathname"; then - func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?" + func_fatal_error "could not locate the posix-modules program - how did you invoke it?" fi ;; esac @@ -189,7 +189,7 @@ func_tmpdir () (umask 077 && mkdir "$tmp") } || { - echo "$0: cannot create a temporary directory in $TMPDIR" >&2 + echo "$progname: cannot create a temporary directory in $TMPDIR" >&2 func_exit 1 } } @@ -198,8 +198,8 @@ func_tmpdir () # outputs to stderr a fatal error message, and terminates the program. func_fatal_error () { - echo "gnulib-tool: *** $1" 1>&2 - echo "gnulib-tool: *** Stop." 1>&2 + echo "$progname: *** $1" 1>&2 + echo "$progname: *** Stop." 1>&2 func_exit 1 } @@ -240,6 +240,7 @@ while test $# -gt 0; do esac done +func_gnulib_dir ( # Get the header modules. LC_ALL=C grep -h '^Gnulib module: ' "$gnulib_dir"/doc/posix-headers/* 2>/dev/null \ @@ -253,3 +254,8 @@ done tr ' ' '\012' | sed -e '/^---$/d' -e '/^and$/d' -e '/^or$/d' -e '/- gnu$/d' } \ | LC_ALL=C sort | LC_ALL=C uniq + +# Local Variables: +# indent-tabs-mode: nil +# whitespace-check-buffer-indent: nil +# End: -- 1.6.0.2