summaryrefslogtreecommitdiff
path: root/gnulib-tool
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2008-09-26 14:47:41 -0600
committerEric Blake <ebb9@byu.net>2008-09-27 16:51:54 -0600
commitbf236140fa6a1c6f2ca5a3f5611c6f9ddea0fb58 (patch)
tree83dca858c738af7d8c101015585a8af042f552a2 /gnulib-tool
parent4640ec2f862cf1e3109270db86668f0b8e9ee710 (diff)
downloadgnulib-bf236140fa6a1c6f2ca5a3f5611c6f9ddea0fb58.tar.gz
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 <ebb9@byu.net>
Diffstat (limited to 'gnulib-tool')
-rwxr-xr-xgnulib-tool22
1 files changed, 14 insertions, 8 deletions
diff --git a/gnulib-tool b/gnulib-tool
index 56b185a381..b0f4c1884e 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -272,14 +272,16 @@ func_exit ()
# func_gnulib_dir
# locates the directory where the gnulib repository lives
+# Input:
+# - progname name of this program
# Sets variables
# - self_abspathname absolute pathname of gnulib-tool
# - 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 +328,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
@@ -351,6 +353,8 @@ func_gnulib_dir ()
# func_tmpdir
# creates a temporary directory.
+# Input:
+# - progname name of this program
# Sets variable
# - tmp pathname of freshly created temporary directory
func_tmpdir ()
@@ -375,7 +379,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
}
}
@@ -398,10 +402,12 @@ fi
# func_fatal_error message
# outputs to stderr a fatal error message, and terminates the program.
+# Input:
+# - progname name of this 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
}