The following reply was made to PR config/2693; it has been noted by GNATS.

From: "Ralf S. Engelschall" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: config/2693: configure script does not work correctly
Date: Sun, 2 Aug 1998 14:19:04 +0200

 In article <[EMAIL PROTECTED]> you wrote:
 
 >  I've attached the file that has the output of the script.
 >
 >  > Seems like some of the substituted values contain
 >  > a "%" character somewhere. The script itself is
 >  > correct, so please do the following to let us
 >  > find the real problem:
 >  > 1. Add "set -x" around the line 914, i.e. after
 >  >    the Creating ... message
 >  > 2. Run configure again and watch the tracing messages
 >  > 3. Somewhere inside the huge sed call the problem
 >  >    occurs. Please send us this trace messages as
 >  >    a reply to this mail.
 
 Thanks for the information. The username/hostname/domainname determination is
 really not robust enough. I've today compared the stuff with some of my other
 GNU Autoconf stuff and the result is a script uhd.sh which I want to use for
 Apache 1.3.2. I've already tested it under FreeBSD, Linux, SunOS and Solaris
 now and it is both more robust and results in more correct output. I append
 it below. Just run it as
 
 $ ./uhd.sh [EMAIL PROTECTED]
 
 and 
 
 $ ./uhd.sh -n [EMAIL PROTECTED]
 
 Both times your (semi-correct) e-mail address should be printed.  The first
 time newline terminated, the second time without a newline. Please give
 feedback if it works for your situation, too.
 
 Thanks.
                                        Ralf S. Engelschall
                                        [EMAIL PROTECTED]
                                        www.engelschall.com
 
 #!/bin/sh
 ##
 ##  uhd.sh -- Username, Hostname, Domainname determination
 ##  Copyright (c) 1998 Ralf S. Engelschall, All Rights Reserved. 
 ##
 
 #
 #   argument line handling
 #
 error=no
 if [ $# -ne 1 -a $# -ne 2 ]; then
     error=yes
 fi
 if [ $# -eq 2 -a ".$1" != ".-n" ]; then
     error=yes
 fi
 if [ $error = yes ]; then
     echo "$0:Error: invalid argument line"
     echo "$0:Usage: $0 [-n] <format-string>"
     echo "Where <format-string> can contain:"
     echo "   %u ...... substituted by determined user name"
     echo "   %h ...... substituted by determined host name"
     echo "   %d ...... substituted by determined domain name"
     exit 1
 fi
 if [ $# -eq 2 ]; then
     newline=no
     format_string="$2"
 else
     newline=yes
     format_string="$1"
 fi
 
 #
 #   initialization
 #
 username=''
 hostname=''
 domainname=''
 
 #
 #   determine username
 #
 username="$LOGNAME"
 if [ ".$username" = . ]; then
     username="$USER"
     if [ ".$username" = . ]; then
         username="`whoami 2>/dev/null |\
                    awk '{ printf("%s", $1); }'`"
         if [ ".$username" = . ]; then
             username="`who am i 2>/dev/null |\
                        awk '{ printf("%s", $1); }'`"
             if [ ".$username" = . ]; then
                 username='unknown'
             fi
         fi
     fi
 fi
 
 #
 #   determine hostname and domainname
 #
 hostname="`uname -n 2>/dev/null |\
            awk '{ printf("%s", $1); }'`"
 if [ ".$hostname" = . ]; then
     hostname="`hostname 2>/dev/null |\
                awk '{ printf("%s", $1); }'`"
     if [ ".$hostname" = . ]; then
         hostname='unknown'
     fi
 fi
 case $hostname in
     *.* )
         domainname=".`echo $hostname | cut -d. -f2-`"
         hostname="`echo $hostname | cut -d. -f1`"
         ;;
 esac
 if [ ".$domainname" = . ]; then
     if [ -f /etc/resolv.conf ]; then
         domainname="`egrep '^[         ]*domain' /etc/resolv.conf | head -1 |\
                      sed -e 's/.*domain//' \
                          -e 's/^[      ]*//' -e 's/^ *//' -e 's/^      *//' \
                          -e 's/^\.//' -e 's/^/./' |\
                      awk '{ printf("%s", $1); }'`"
         if [ ".$domainname" = . ]; then
             domainname="`egrep '^[     ]*search' /etc/resolv.conf | head -1 |\
                          sed -e 's/.*search//' \
                              -e 's/^[[         ]]*//' -e 's/^ *//' -e 's/^     
*//' \
                              -e 's/ .*//' -e 's/       .*//' \
                              -e 's/^\.//' -e 's/^/./' |\
                          awk '{ printf("%s", $1); }'`"
         fi
     fi
 fi
 
 #
 #   create result string
 #
 if [ ".$newline" = .yes ]; then
     echo $format_string |\
     sed -e "s;%u;$username;g" \
         -e "s;%h;$hostname;g" \
         -e "s;%d;$domainname;g"
 else
     echo "${format_string}&" |\
     sed -e "s;%u;$username;g" \
         -e "s;%h;$hostname;g" \
         -e "s;%d;$domainname;g" |\
     awk '-F&' '{ printf("%s", $1); }'
 fi
 

Reply via email to