view octave-bug.in @ 10843:229675bb7647 ss-3-3-52

version is now 3.3.52
author John W. Eaton <jwe@octave.org>
date Sun, 01 Aug 2010 11:49:45 -0400
parents d36f8c473dff
children
line wrap: on
line source

#! /bin/sh -
#
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2004,
#               2005, 2006, 2009 John W. Eaton
#
# This file is part of Octave.
# 
# Octave is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
# 
# Octave is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Octave; see the file COPYING.  If not, see
# <http://www.gnu.org/licenses/>.

# octave-bug - create a bug report and mail it to the bug-octave
# mailing list.
#
# Patterned after the bashbug script from bash 1.14.

# Configuration:  these variables are filled in when running make to
# compile Octave.

config_opts=%OCTAVE_CONF_config_opts%
VERSION=%OCTAVE_CONF_VERSION%
SED=%OCTAVE_CONF_SED%
MACHINE=%OCTAVE_CONF_CANONICAL_HOST_TYPE%
F77=%OCTAVE_CONF_F77%
FFLAGS=%OCTAVE_CONF_FFLAGS%
FPICFLAG=%OCTAVE_CONF_FPICFLAG%
FLIBS=%OCTAVE_CONF_FLIBS%
CPPFLAGS=%OCTAVE_CONF_CPPFLAGS%
INCFLAGS=%OCTAVE_CONF_INCFLAGS%
CC=%OCTAVE_CONF_CC%
CC_VERSION=%OCTAVE_CONF_CC_VERSION%
CFLAGS=%OCTAVE_CONF_CFLAGS%
CPICFLAG=%OCTAVE_CONF_CPICFLAG%
CXX=%OCTAVE_CONF_CXX%
CXX_VERSION=%OCTAVE_CONF_CXX_VERSION%
CXXFLAGS=%OCTAVE_CONF_CXXFLAGS%
CXXPICFLAG=%OCTAVE_CONF_CXXPICFLAG%
LD_CXX=%OCTAVE_CONF_LD_CXX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QRUPDATE_LIBS%
READLINE_LIBS=%OCTAVE_CONF_READLINE_LIBS%
REGEX_LIBS=%OCTAVE_CONF_REGEX_LIBS%
TERM_LIBS=%OCTAVE_CONF_TERM_LIBS%
UMFPACK_CPPFLAGS=%OCTAVE_CONF_UMFPACK_CPPFLAGS%
UMFPACK_LDFLAGS=%OCTAVE_CONF_UMFPACK_LDFLAGS%
UMFPACK_LIBS=%OCTAVE_CONF_UMFPACK_LIBS%
X11_INCFLAGS=%OCTAVE_CONF_X11_INCFLAGS%
X11_LIBS=%OCTAVE_CONF_X11_LIBS%
Z_CPPFLAGS=%OCTAVE_CONF_Z_CPPFLAGS%
Z_LDFLAGS=%OCTAVE_CONF_Z_LDFLAGS%
Z_LIBS=%OCTAVE_CONF_Z_LIBS%

DEFS=%OCTAVE_CONF_DEFS%

: ${USER=$LOGNAME}

CC_AND_VERSION=
if test -n "$CC_VERSION"; then
  CC_AND_VERSION="$CC, version $CC_VERSION"
fi

CXX_AND_VERSION=
if test -n "$CXX_VERSION"; then
  CXX_AND_VERSION="$CXX, version $CXX_VERSION"
fi

PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:$PATH
export PATH

TEMP=/tmp/octave-bug.$$

if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then
  if [ -x /usr/bin/editor ]; then
    DEFEDITOR=editor
  elif [ -x /usr/local/bin/ce ]; then
    DEFEDITOR=ce
  elif [ -x /usr/local/bin/emacs ]; then
    DEFEDITOR=emacs
  elif [ -x /usr/contrib/bin/emacs ]; then
    DEFEDITOR=emacs
  elif [ -x /usr/bin/emacs ]; then
    DEFEDITOR=emacs
  elif [ -x /usr/bin/xemacs ]; then
    DEFEDITOR=xemacs
  elif [ -x /usr/contrib/bin/jove ]; then
    DEFEDITOR=jove
  elif [ -x /usr/local/bin/jove ]; then
    DEFEDITOR=jove
  elif [ -x /usr/bin/vi ]; then
    DEFEDITOR=vi
  else
    echo "octave-bug: No default editor found: attempting to use vi" >&2
    DEFEDITOR=vi
  fi
fi

: ${EDITOR=$DEFEDITOR}

if [ -z "$DEFPAGER" ] && [ -z "$PAGER" ]; then
  if [ -x /usr/bin/pager ]; then
    DEFPAGER=pager
  elif [ -x /usr/bin/less ]; then
    DEFPAGER=less
  elif [ -x /bin/less ]; then
    DEFPAGER=less
  elif [ -x /usr/local/bin/less ]; then
    DEFPAGER=less
  elif [ -x /usr/bin/more ]; then
    DEFPAGER=more
  elif [ -x /bin/more ]; then
    DEFPAGER=more
  elif [ -x /usr/bin/pg ]; then
    DEFPAGER=pg
  elif [ -x /bin/pg ]; then
    DEFPAGER=pg
  else
    echo "octave-bug: No default pager found: attempting to use more" >&2
    DEFPAGER=more
  fi
fi

: ${PAGER=$DEFPAGER}

trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15
trap 'rm -f $TEMP $TEMP.x' 0

UN=
if (uname) > /dev/null 2>&1; then
  UN=`uname -a`
fi

HAVE_FMT=false
if (fmt < /dev/null) > /dev/null 2>&1; then
  HAVE_FMT=true
fi

# Check whether to use -n or \c to keep echo from printing a newline
# character.  Stolen from autoconf, which borrowed the idea from dist 3.0.

if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
  if (echo -n testing; echo 1,2,3) | $SED s/-n/xn/ | grep xn >/dev/null; then
    echo_n=
    echo_c='
'
  else
    echo_n=-n
    echo_c=
  fi
else
  echo_n=
  echo_c='\c'
fi

ss_p=`echo $VERSION | grep "^ss-"`
if test -n "$ss_p"; then
  BUGADDR="maintainers@octave.org"
else
  pretest_p=`echo $VERSION \
    | $SED 's,.*\.\([0-9]*\).*,\1,' \
    | grep -v '\.' \
    | grep '[0-9]'`

  if test -n "$pretest_p" && test "$pretest_p" -ge 90; then
    BUGADDR="maintainers@octave.org"
  else
    BUGADDR="bug@octave.org"
  fi
fi

SUBJECT="[50 character or so descriptive subject here (for reference)]"
if test $# -gt 0; then
  case "$1" in
    -s)
      shift
      if test $# -gt 0; then
        SUBJECT="$1"
        shift
      else
        echo "usage: octave-bug [-s subject]"
        exit 1
      fi
    ;;
  esac
fi

cat > $TEMP << EOF
To: $BUGADDR
EOF
if test -n "$USER"; then
cat >> $TEMP << EOF
Cc: $USER
EOF
fi
cat >> $TEMP << EOF
Subject: $SUBJECT
--------
Bug report for Octave $VERSION configured for $MACHINE

Description:
-----------

  * Please replace this item with a detailed description of the
    problem.  Suggestions or general comments are also welcome.

Repeat-By:
---------

  * Please replace this item with a description of the sequence of
    events that causes the problem to occur. 

Fix:
---

  * If possible, replace this item with a description of how to
    fix the problem (if you don't have a fix for the problem, don't
    include this section, but please do submit your report anyway).



Configuration (please do not edit this section):
-----------------------------------------------

uname output:      $UN
configure opts:    $config_opts
SED:               $SED
Fortran compiler:  $F77
FFLAGS:            $FFLAGS
FLIBS:             $FLIBS
CPPFLAGS:          $CPPFLAGS
INCFLAGS:          $INCFLAGS
C compiler:        $CC_AND_VERSION
CFLAGS:            $CFLAGS
CPICFLAG:          $CPICFLAG
C++ compiler:      $CXX_AND_VERSION
CXXFLAGS:          $CXXFLAGS
CXXPICFLAG:        $CXXPICFLAG
LD_CXX:            $LD_CXX
LDFLAGS:           $LDFLAGS
LIBFLAGS:          $LIBFLAGS
RLD_FLAG:          $RLD_FLAG
LEXLIB:            $LEXLIB
LIBS:              $LIBS
AMD_CPPFLAGS:      $AMD_CPPFLAGS
AMD_LDFLAGS:       $AMD_LDFLAGS
AMD_LIBS:          $AMD_LIBS
ARPACK_LIBS:       $ARPACK_LIBS
BLAS_LIBS:         $BLAS_LIBS
CAMD_CPPFLAGS:     $CAMD_CPPFLAGS
CAMD_LDFLAGS:      $CAMD_LDFLAGS
CAMD_LIBS:         $CAMD_LIBS
CARBON_LIBS:       $CARBON_LIBS
CCOLAMD_CPPFLAGS:  $CCOLAMD_CPPFLAGS
CCOLAMD_LDFLAGS:   $CCOLAMD_LDFLAGS
CCOLAMD_LIBS:      $CCOLAMD_LIBS
CHOLMOD_CPPFLAGS:  $CHOLMOD_CPPFLAGS
CHOLMOD_LDFLAGS:   $CHOLMOD_LDFLAGS
CHOLMOD_LIBS:      $CHOLMOD_LIBS
COLAMD_CPPFLAGS:   $COLAMD_CPPFLAGS
COLAMD_LDFLAGS:    $COLAMD_LDFLAGS
COLAMD_LIBS:       $COLAMD_LIBS
CURL_CPPFLAGS:     $CURL_CPPFLAGS
CURL_LDFLAGS:      $CURL_LDFLAGS
CURL_LIBS:         $CURL_LIBS
CXSPARSE_CPPFLAGS: $CXSPARSE_CPPFLAGS
CXSPARSE_LDFLAGS:  $CXSPARSE_LDFLAGS
CXSPARSE_LIBS:     $CXSPARSE_LIBS
DL_LIBS:           $DL_LIBS
FFTW3_CPPFLAGS:    $FFTW3_CPPFLAGS
FFTW3_LDFLAGS:     $FFTW3_LDFLAGS
FFTW3_LIBS:        $FFTW3_LIBS
FFTW3F_CPPFLAGS:   $FFTW3F_CPPFLAGS
FFTW3F_LDFLAGS:    $FFTW3F_LDFLAGS
FFTW3F_LIBS:       $FFTW3F_LIBS
GRAPHICS_LIBS:     $GRAPHICS_LIBS
GLPK_CPPFLAGS:     $GLPK_CPPFLAGS
GLPK_LDFLAGS:      $GLPK_LDFLAGS
GLPK_LIBS:         $GLPK_LIBS
HDF5_CPPFLAGS:     $HDF5_CPPFLAGS
HDF5_LDFLAGS:      $HDF5_LDFLAGS
HDF5_LIBS:         $HDF5_LIBS
OPENGL_LIBS:       $OPENGL_LIBS
PTHREAD_CFLAGS:    $PTHREAD_CFLAGS
PTHREAD_LIBS:      $PTHREAD_LIBS
QHULL_CPPFLAGS:    $QHULL_CPPFLAGS
QHULL_LDFLAGS:     $QHULL_LDFLAGS
QHULL_LIBS:        $QHULL_LIBS
QRUPDATE_LIBS:     $QRUPDATE_LIBS
READLINE_LIBS:     $READLINE_LIBS
REGEX_LIBS:        $REGEX_LIBS
TERM_LIBS:         $TERM_LIBS
UMFPACK_LIBS:      $UMFPACK_LIBS
X11_INCFLAGS:      $X11_INCFLAGS
X11_LIBS:          $X11_LIBS
Z_CPPFLAGS:        $Z_CPPFLAGS
Z_LDFLAGS:         $Z_LDFLAGS
Z_LIBS:            $Z_LIBS
DEFS:

EOF

if $HAVE_FMT; then
  echo $DEFS | fmt | $SED 's/^/  /' >> $TEMP
else
  echo $DEFS >> $TEMP
fi

if test $# -gt 0; then
  if test -f "$1"; then
    cat >> $TEMP << EOF

User-preferences (please do not edit this section):
--------------------------------------------------

EOF
    cat $1 >> $TEMP
  fi
fi

chmod u+w $TEMP
cp $TEMP $TEMP.x

status=0

editing=true

while $editing; do
  if $EDITOR $TEMP; then
    while $editing; do
      echo $echo_n "(a)bort, (e)dit, (l)ist, (s)end? $echo_c"
      read ans
      case "$ans" in
        a* | A*)
          status=1
          editing=false
        ;;
        e* | E*)
          break;
        ;;
        l* | L*)
          $PAGER $TEMP
        ;;
        s* | S*)
          editing=false
        ;;
      esac
    done
  else
    echo "problems with edit -- no bug report submitted"
    status=1
    editing=false
  fi
done

if test $status -eq 0; then
  if cmp -s $TEMP $TEMP.x; then
    echo "file not changed -- no bug report submitted"
    status=1
  elif test `wc $TEMP | awk '{print $1}'` -eq 0; then
    echo "empty bug report file -- not submitted"
    status=1
  else

# Try to extract the recipient address, in case the To: line in the
# message template has been changed.  Also get cc: lines.

    TO_ADDR=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^[Tt][Oo]://p'`
    CC_ADDR=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^[Cc][Cc]://p'`

    if test -z "$TO_ADDR"; then
      echo "no valid \`To:' field found in header -- using $BUGADDR instead"
    else
      BUGADDR="$TO_ADDR"      
    fi

    BUGADDR="$BUGADDR $CC_ADDR"

    TMP_SUB=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^Subject://p'`

    if test -n "$TMP_SUB"; then
      SUBJECT="$TMP_SUB"
    fi

# Delete the `--------' separator in the message.

# Don't pretty-print this.  Odd whitespace kills Ultrix AWK!

    awk 'BEGIN{in_header=1;} /^--------[ \t]*$/ {
      if (in_header) { in_header=0; print ""; next; }
    } { print $0; }' $TEMP > $TEMP.x

# Now try to mail it.

    # indicate that we have not yet sent email successfully
    status=11

    if test $status -ne 0; then
      ( mailx -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1
      status=$?
      if test $status -ne 0; then
        ( Mail -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1
        status=$?
        if test $status -ne 0; then
          ( /usr/ucb/mail -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1
          status=$?
          # make /bin/mail our last resort -- it ignores the subject line
          if test $status -ne 0; then
            ( /bin/mail $BUGADDR < $TEMP.x ) > /dev/null 2>&1
            status=$?
            if test $status -ne 0; then
              echo "unable to send mail..."
            fi
          fi
        fi
      fi
    fi
  fi
fi

if test $status -ne 0; then
  dead_bug_file=$HOME/dead-octave-bug
  looking_for_file=true;
  n=1
  while $looking_for_file; do
    if test -f "$dead_bug_file-$n"; then
      n=`expr $n + 1`
    else
      looking_for_file=false
      dead_bug_file=$dead_bug_file-$n
    fi
  done
  echo "saving message in $dead_bug_file";
  cat $TEMP >> $dead_bug_file;
  exit 1
else
  echo "bug report sent to: $TO_ADDR"
  echo "             cc to: $CC_ADDR"
fi

exit $status