<<< Date Index >>>     <<< Thread Index >>>

Re: [Mutt] #1615: mutt breaks if _POSIX2_VERSION=200111 with recent coreutils



#1615: mutt breaks if _POSIX2_VERSION=200111 with recent coreutils

Changes (by brendan):

  * component:  mutt => build
  * milestone:  => 1.6

Old description:

> {{{
> Package: mutt
> Version: 1.5.4-1
> Severity: normal
>
> [NOTE: this bug report has been submitted to the debian BTS as
> Bug#204904.
> Please Cc all your replies to 204904@xxxxxxxxxxxxxxx .]
>
> From: Paul Eggert <eggert@xxxxxxxxxxx>
> Subject: mutt breaks if _POSIX2_VERSION=200111 with recent coreutils
> Date: 10 Aug 2003 23:29:11 -0700
>
> Here are some fixes for some POSIX-compliance problems with "mutt".
>
> POSIX 1003.1-2001 has removed support for commands like
> "head -1" (you are supposed to use "head -n 1"),
> "tail -1" (you are supposed to use "tail -n 1"),
> mutt still uses the old forms, which don't work any more on some
> strict POSIX hosts (e.g., GNU coreutils with _POSIX2_VERSION=200111
> in your environment).
>
> Also, I noticed that mutt uses the -a option of test.  This isn't
> allowed on strict POSIX 1003.1-2001 hosts; you're supposed to use &&
> in the shell instead.  Similarly, mutt uses egrep, even though
> POSIX has removed that command (you're supposed to use "grep -E").
> This stuff still works with Debian but I figured I could submit
> patches for that too, while I was at it.
>
> Here is a patch.  This patch avoids commands like "head -n 1", since
> they don't work on some older (non-Debian) hosts that Mutt is supposed
> to port to.  I'll CC: this message to the Mutt maintainer since the
> patches all seem relevant to mutt (except for the debian/* files).
> Recent Debian unstable versions reportedly are behaving as if
> _POSIX2_VERSION=200111, so the priority of this is increasing now, as
> they'll break mutt unless this patch is installed.
>
> One more thing: I noticed a "TZ=GMT" in mkchangelog.sh.  That's not
> portable POSIX code, and has undefined behavior.  You're supposed to
> say "TZ=GMT0".  The patch below fixes this, too.
>
> diff -pru mutt-1.5.4-1/configure.in mutt-1.5.4-1-fix/configure.in
> --- mutt-1.5.4-1/configure.in   2003-03-19 14:30:38.000000000 -0800
> +++ mutt-1.5.4-1-fix/configure.in       2003-08-10 23:28:44.000000000
> -0700
> @@ -231,7 +231,7 @@ main ()
>         done
>          AC_CHECK_LIB($cf_ncurses, initscr,
>                  [MUTTLIBS="$MUTTLIBS -l$cf_ncurses"
> -                if test x$mutt_cv_curses = x/usr -a -d
> /usr/include/ncurses; then
> +                if test x$mutt_cv_curses = x/usr && test -d
> /usr/include/ncurses; then
>                          CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses"
>                  fi
>
> @@ -722,7 +722,7 @@ AC_ARG_ENABLE(warnings, [  --disable-war
>          mutt_cv_warnings=no
>  fi])
>
> -if test x$GCC = xyes -a $mutt_cv_warnings = yes; then
> +if test x$GCC = xyes && test $mutt_cv_warnings = yes; then
>          CFLAGS="-Wall -pedantic $CFLAGS"
>  fi
>
> @@ -931,7 +931,7 @@ wc_funcs=maybe
>  AC_ARG_WITH(wc-funcs, [  --without-wc-funcs         Do not use the
> system's wchar_t functions],
>          wc_funcs=$withval)
>
> -if test "$wc_funcs" != yes -a "$wc_funcs" != no; then
> +if test "$wc_funcs" != yes && test "$wc_funcs" != no; then
>          AC_CACHE_CHECK([for wchar_t functions], mutt_cv_wc_funcs,
>                  mutt_cv_wc_funcs=no
>                  AC_TRY_LINK([
> diff -pru mutt-1.5.4-1/contrib/iconv/make.sh
> mutt-1.5.4-1-fix/contrib/iconv/make.sh
> --- mutt-1.5.4-1/contrib/iconv/make.sh  2002-01-24 04:11:18.000000000
> -0800
> +++ mutt-1.5.4-1-fix/contrib/iconv/make.sh      2003-08-10
> 23:28:44.000000000 -0700
> @@ -16,7 +16,7 @@ test -d $LIBICONV/libcharset/tools || {
>
>  for f in $LIBICONV/libcharset/tools/* ; do
>         rm -f tmp.rc.
> -       ( head -3 $f | grep -q 'locale name.*locale
> charmap.*locale_charset' ) && (
> +       ( sed 3q $f | grep -q 'locale name.*locale
> charmap.*locale_charset' ) && (
>                 sed '1,/^$/d' $f | awk '($4 != $3) { printf ("iconv-hook
> %s %s\n", $4, $3); }' | \
>                         sed -e 's/^iconv-hook SJIS /iconv-hook Shift_JIS
> /gi' |
>                         sort -u > tmp.rc )
> diff -pru mutt-1.5.4-1/debian/scripts/archmap
> mutt-1.5.4-1-fix/debian/scripts/archmap
> --- mutt-1.5.4-1/debian/scripts/archmap 2003-08-10 23:20:23.000000000
> -0700
> +++ mutt-1.5.4-1-fix/debian/scripts/archmap     2003-08-10
> 23:28:44.000000000 -0700
> @@ -11,7 +11,7 @@ else
>                 arch=$(dpkg --print-gnu-build-architecture)
>         fi
>  fi
> -set -- $(egrep ".* $arch( .*|$)" debian/scripts/archmap)
> +set -- $(grep -E ".* $arch( .*|$)" debian/scripts/archmap)
>  if [ -z $2 ];then
>                 arch=$arch
>  else
> diff -pru mutt-1.5.4-1/debian/scripts/source.unpack
> mutt-1.5.4-1-fix/debian/scripts/source.unpack
> --- mutt-1.5.4-1/debian/scripts/source.unpack   2003-08-10
> 23:20:23.000000000 -0700
> +++ mutt-1.5.4-1-fix/debian/scripts/source.unpack       2003-08-10
> 23:28:44.000000000 -0700
> @@ -7,8 +7,8 @@ mkdir -p $STAMP_DIR/upstream/tarballs/ $
>  if [ ! -z "$SRC_TAR_DIR" -a -d "$SRC_TAR_DIR" ];then
>         files=$(find $SRC_TAR_DIR -type f|sort)
>  else
> -       VER=$(dpkg-parsechangelog 2>&1|egrep ^Version|cut -d " " -f 2|cut
> -d "-" -f 1)
> -       SRC=$(dpkg-parsechangelog 2>&1|egrep ^Source|cut -d " " -f 2-)
> +       VER=$(dpkg-parsechangelog 2>&1|grep '^Version'|cut -d " " -f
> 2|cut -d "-" -f 1)
> +       SRC=$(dpkg-parsechangelog 2>&1|grep '^Source'|cut -d " " -f 2-)
>         files=../${SRC}_${VER}.orig.tar.gz
>  fi
>  for f in $files;do
> diff -pru mutt-1.5.4-1/doc/manual.sgml.head
> mutt-1.5.4-1-fix/doc/manual.sgml.head
> --- mutt-1.5.4-1/doc/manual.sgml.head   2003-03-03 23:49:49.000000000
> -0800
> +++ mutt-1.5.4-1-fix/doc/manual.sgml.head       2003-08-10
> 23:28:44.000000000 -0700
> @@ -1555,7 +1555,7 @@ something like <tt/unhook send-hook/.
>  All string patterns in Mutt including those in more complex
>  <ref id="patterns" name="patterns"> must be specified
>  using regular expressions (regexp) in the ``POSIX extended'' syntax
> (which
> -is more or less the syntax used by egrep and GNU awk).  For your
> +is more or less the syntax used by grep -E and GNU awk).  For your
>  convenience, we have included below a brief description of this syntax.
>
>  The search is case sensitive if the pattern contains at least one upper
> diff -pru mutt-1.5.4-1/mkchangelog.sh mutt-1.5.4-1-fix/mkchangelog.sh
> --- mutt-1.5.4-1/mkchangelog.sh 2002-12-22 11:50:21.000000000 -0800
> +++ mutt-1.5.4-1-fix/mkchangelog.sh     2003-08-10 23:31:33.000000000
> -0700
> @@ -1,5 +1,5 @@
>  #!/bin/sh
>
> -TZ=GMT; export TZ
> -date="`head -1 ChangeLog | awk '{print $1, $2}'`"
> +TZ=GMT0; export TZ
> +date="`awk '{print $1, $2; exit}' ChangeLog`"
>  cvs -z9 log -d ">$date" | perl ./cvslog2changelog.pl
> diff -pru mutt-1.5.4-1/muttbug.sh.in mutt-1.5.4-1-fix/muttbug.sh.in
> --- mutt-1.5.4-1/muttbug.sh.in  2002-12-11 02:31:29.000000000 -0800
> +++ mutt-1.5.4-1-fix/muttbug.sh.in      2003-08-10 23:28:44.000000000
> -0700
> @@ -41,7 +41,7 @@ include_file ()
>  {
>         echo
>         echo "--- Begin $1"
> -       sed -e 's/^-/- -/' $1 | egrep -v '^[    ]*(#|$)'
> +       sed -e '/^[      ]*#/d; /^[      ]*$/d; s/^-/- -/' $1
>         echo "--- End $1"
>         echo
>  }
> @@ -201,7 +201,7 @@ if rpm -q mutt > /dev/null 2> /dev/null
>         RPMPACKAGER="`rpm -q -i mutt | sed -n -e 's/^Packager *: *//p'`"
>  fi
>
> -MUTTVERSION="`mutt -v | head -1 | awk '{print $2}'`"
> +MUTTVERSION="`mutt -v | awk '{print $2; exit}'`"
>  test "$DPKG" = "yes" && SUBMIT="$SUBMIT, $DEBIAN_SUBMIT"
>
>  exec > ${TEMPLATE}
> @@ -233,7 +233,7 @@ else
>         echo "System Version: `uname -a`"
>         test -z "$RPMPACKAGER" || echo "RPM Packager: $RPMPACKAGER";
>         test -f /etc/redhat-release && echo "RedHat Release: `cat /etc
> /redhat-release`"
> -       test -f /etc/SuSE-release && echo "SuSE Release: `head -1 /etc
> /SuSE-release`"
> +       test -f /etc/SuSE-release && echo "SuSE Release: `sed 1q /etc
> /SuSE-release`"
>         # Please provide more of these if you have any.
>  fi
>

>

>

> >How-To-Repeat:
>
> >Fix:
> }}}

New description:

 {{{
 Package: mutt
 Version: 1.5.4-1
 Severity: normal

 [NOTE: this bug report has been submitted to the debian BTS as Bug#204904.
 Please Cc all your replies to 204904@xxxxxxxxxxxxxxx .]

 From: Paul Eggert <eggert@xxxxxxxxxxx>
 Subject: mutt breaks if _POSIX2_VERSION=200111 with recent coreutils
 Date: 10 Aug 2003 23:29:11 -0700

 Here are some fixes for some POSIX-compliance problems with "mutt".

 POSIX 1003.1-2001 has removed support for commands like
 "head -1" (you are supposed to use "head -n 1"),
 "tail -1" (you are supposed to use "tail -n 1"),
 mutt still uses the old forms, which don't work any more on some
 strict POSIX hosts (e.g., GNU coreutils with _POSIX2_VERSION=200111
 in your environment).

 Also, I noticed that mutt uses the -a option of test.  This isn't
 allowed on strict POSIX 1003.1-2001 hosts; you're supposed to use &&
 in the shell instead.  Similarly, mutt uses egrep, even though
 POSIX has removed that command (you're supposed to use "grep -E").
 This stuff still works with Debian but I figured I could submit
 patches for that too, while I was at it.

 Here is a patch.  This patch avoids commands like "head -n 1", since
 they don't work on some older (non-Debian) hosts that Mutt is supposed
 to port to.  I'll CC: this message to the Mutt maintainer since the
 patches all seem relevant to mutt (except for the debian/* files).
 Recent Debian unstable versions reportedly are behaving as if
 _POSIX2_VERSION=200111, so the priority of this is increasing now, as
 they'll break mutt unless this patch is installed.

 One more thing: I noticed a "TZ=GMT" in mkchangelog.sh.  That's not
 portable POSIX code, and has undefined behavior.  You're supposed to
 say "TZ=GMT0".  The patch below fixes this, too.

 diff -pru mutt-1.5.4-1/configure.in mutt-1.5.4-1-fix/configure.in
 --- mutt-1.5.4-1/configure.in   2003-03-19 14:30:38.000000000 -0800
 +++ mutt-1.5.4-1-fix/configure.in       2003-08-10 23:28:44.000000000
 -0700
 @@ -231,7 +231,7 @@ main ()
         done
          AC_CHECK_LIB($cf_ncurses, initscr,
                  [MUTTLIBS="$MUTTLIBS -l$cf_ncurses"
 -                if test x$mutt_cv_curses = x/usr -a -d
 /usr/include/ncurses; then
 +                if test x$mutt_cv_curses = x/usr && test -d
 /usr/include/ncurses; then
                          CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses"
                  fi

 @@ -722,7 +722,7 @@ AC_ARG_ENABLE(warnings, [  --disable-war
          mutt_cv_warnings=no
  fi])

 -if test x$GCC = xyes -a $mutt_cv_warnings = yes; then
 +if test x$GCC = xyes && test $mutt_cv_warnings = yes; then
          CFLAGS="-Wall -pedantic $CFLAGS"
  fi

 @@ -931,7 +931,7 @@ wc_funcs=maybe
  AC_ARG_WITH(wc-funcs, [  --without-wc-funcs         Do not use the
 system's wchar_t functions],
          wc_funcs=$withval)

 -if test "$wc_funcs" != yes -a "$wc_funcs" != no; then
 +if test "$wc_funcs" != yes && test "$wc_funcs" != no; then
          AC_CACHE_CHECK([for wchar_t functions], mutt_cv_wc_funcs,
                  mutt_cv_wc_funcs=no
                  AC_TRY_LINK([
 diff -pru mutt-1.5.4-1/contrib/iconv/make.sh
 mutt-1.5.4-1-fix/contrib/iconv/make.sh
 --- mutt-1.5.4-1/contrib/iconv/make.sh  2002-01-24 04:11:18.000000000
 -0800
 +++ mutt-1.5.4-1-fix/contrib/iconv/make.sh      2003-08-10
 23:28:44.000000000 -0700
 @@ -16,7 +16,7 @@ test -d $LIBICONV/libcharset/tools || {

  for f in $LIBICONV/libcharset/tools/* ; do
         rm -f tmp.rc.
 -       ( head -3 $f | grep -q 'locale name.*locale
 charmap.*locale_charset' ) && (
 +       ( sed 3q $f | grep -q 'locale name.*locale
 charmap.*locale_charset' ) && (
                 sed '1,/^$/d' $f | awk '($4 != $3) { printf ("iconv-hook
 %s %s\n", $4, $3); }' | \
                         sed -e 's/^iconv-hook SJIS /iconv-hook Shift_JIS
 /gi' |
                         sort -u > tmp.rc )
 diff -pru mutt-1.5.4-1/debian/scripts/archmap
 mutt-1.5.4-1-fix/debian/scripts/archmap
 --- mutt-1.5.4-1/debian/scripts/archmap 2003-08-10 23:20:23.000000000
 -0700
 +++ mutt-1.5.4-1-fix/debian/scripts/archmap     2003-08-10
 23:28:44.000000000 -0700
 @@ -11,7 +11,7 @@ else
                 arch=$(dpkg --print-gnu-build-architecture)
         fi
  fi
 -set -- $(egrep ".* $arch( .*|$)" debian/scripts/archmap)
 +set -- $(grep -E ".* $arch( .*|$)" debian/scripts/archmap)
  if [ -z $2 ];then
                 arch=$arch
  else
 diff -pru mutt-1.5.4-1/debian/scripts/source.unpack
 mutt-1.5.4-1-fix/debian/scripts/source.unpack
 --- mutt-1.5.4-1/debian/scripts/source.unpack   2003-08-10
 23:20:23.000000000 -0700
 +++ mutt-1.5.4-1-fix/debian/scripts/source.unpack       2003-08-10
 23:28:44.000000000 -0700
 @@ -7,8 +7,8 @@ mkdir -p $STAMP_DIR/upstream/tarballs/ $
  if [ ! -z "$SRC_TAR_DIR" -a -d "$SRC_TAR_DIR" ];then
         files=$(find $SRC_TAR_DIR -type f|sort)
  else
 -       VER=$(dpkg-parsechangelog 2>&1|egrep ^Version|cut -d " " -f 2|cut
 -d "-" -f 1)
 -       SRC=$(dpkg-parsechangelog 2>&1|egrep ^Source|cut -d " " -f 2-)
 +       VER=$(dpkg-parsechangelog 2>&1|grep '^Version'|cut -d " " -f 2|cut
 -d "-" -f 1)
 +       SRC=$(dpkg-parsechangelog 2>&1|grep '^Source'|cut -d " " -f 2-)
         files=../${SRC}_${VER}.orig.tar.gz
  fi
  for f in $files;do
 diff -pru mutt-1.5.4-1/doc/manual.sgml.head
 mutt-1.5.4-1-fix/doc/manual.sgml.head
 --- mutt-1.5.4-1/doc/manual.sgml.head   2003-03-03 23:49:49.000000000
 -0800
 +++ mutt-1.5.4-1-fix/doc/manual.sgml.head       2003-08-10
 23:28:44.000000000 -0700
 @@ -1555,7 +1555,7 @@ something like <tt/unhook send-hook/.
  All string patterns in Mutt including those in more complex
  <ref id="patterns" name="patterns"> must be specified
  using regular expressions (regexp) in the ``POSIX extended'' syntax
 (which
 -is more or less the syntax used by egrep and GNU awk).  For your
 +is more or less the syntax used by grep -E and GNU awk).  For your
  convenience, we have included below a brief description of this syntax.

  The search is case sensitive if the pattern contains at least one upper
 diff -pru mutt-1.5.4-1/mkchangelog.sh mutt-1.5.4-1-fix/mkchangelog.sh
 --- mutt-1.5.4-1/mkchangelog.sh 2002-12-22 11:50:21.000000000 -0800
 +++ mutt-1.5.4-1-fix/mkchangelog.sh     2003-08-10 23:31:33.000000000
 -0700
 @@ -1,5 +1,5 @@
  #!/bin/sh

 -TZ=GMT; export TZ
 -date="`head -1 ChangeLog | awk '{print $1, $2}'`"
 +TZ=GMT0; export TZ
 +date="`awk '{print $1, $2; exit}' ChangeLog`"
  cvs -z9 log -d ">$date" | perl ./cvslog2changelog.pl
 diff -pru mutt-1.5.4-1/muttbug.sh.in mutt-1.5.4-1-fix/muttbug.sh.in
 --- mutt-1.5.4-1/muttbug.sh.in  2002-12-11 02:31:29.000000000 -0800
 +++ mutt-1.5.4-1-fix/muttbug.sh.in      2003-08-10 23:28:44.000000000
 -0700
 @@ -41,7 +41,7 @@ include_file ()
  {
         echo
         echo "--- Begin $1"
 -       sed -e 's/^-/- -/' $1 | egrep -v '^[    ]*(#|$)'
 +       sed -e '/^[      ]*#/d; /^[      ]*$/d; s/^-/- -/' $1
         echo "--- End $1"
         echo
  }
 @@ -201,7 +201,7 @@ if rpm -q mutt > /dev/null 2> /dev/null
         RPMPACKAGER="`rpm -q -i mutt | sed -n -e 's/^Packager *: *//p'`"
  fi

 -MUTTVERSION="`mutt -v | head -1 | awk '{print $2}'`"
 +MUTTVERSION="`mutt -v | awk '{print $2; exit}'`"
  test "$DPKG" = "yes" && SUBMIT="$SUBMIT, $DEBIAN_SUBMIT"

  exec > ${TEMPLATE}
 @@ -233,7 +233,7 @@ else
         echo "System Version: `uname -a`"
         test -z "$RPMPACKAGER" || echo "RPM Packager: $RPMPACKAGER";
         test -f /etc/redhat-release && echo "RedHat Release: `cat /etc
 /redhat-release`"
 -       test -f /etc/SuSE-release && echo "SuSE Release: `head -1 /etc
 /SuSE-release`"
 +       test -f /etc/SuSE-release && echo "SuSE Release: `sed 1q /etc
 /SuSE-release`"
         # Please provide more of these if you have any.
  fi






 >How-To-Repeat:

 >Fix:
 }}}

-- 
Ticket URL: <http://dev.mutt.org/trac/ticket/1615#comment:4>