Bug#1127091: /usr/sbin/update-info-dir: Post-install processing of /etc/environment does not tolerate comments

Preuße, Hilmar <[email protected]>
Newsgroups gmane.linux.debian.devel.tetex
Message-ID <03bb478e-86b6-451e-b960-fc6ff48613f2__1040.73330746672$1770482130$gmane$org@web.de>
Am 07.02.2026 um 05:17 schrieb horsey_guy:

Hello,

> I forgot to mention was that `update-info-dir` correctly handled
> comments before as it simply sourced the environment file.>

I'm aware of this, but this caused other issues, described in #1114610.

Try the attached version.

Hilmar
-- 
sigfault
update-info-dir (text/plain, 1.8 KB)
#!/bin/sh
# update-info-dir
# create a dir file from all installed info files
# Copyright 2009, 2014 Norbert Preining
# GPLv2

INFODIR=/usr/share/info

set -e

#
# since user's environment is taken over into root account when sudo-ing
# we don't want that one's user LANGUAGE setting changes the messages in
# the dir file. Unset LANGUAGE and reload /etc/environment to get
# the system wide settings. See bug #536476
unset LANGUAGE
unset LANG
if [ -r /etc/environment ] ; then
  exec 9<&0 </etc/environment
  while read -r env
  echo $env | grep -q "^#" && env=""
  do if [ -n "$env" ]
     then export "$env"
  fi; done
  exec 0<&9 9<&-
fi
if [ -r /etc/default/locale ] ; then
  . /etc/default/locale
fi

Help ()
{
    echo "\
SYNOPSIS: update-info-dir [-h,--help] [info-directory]

(re-)creates the index of available documentation in info format
(the file /usr/share/info/dir) which is usually presented by info browsers
on startup."

    exit 0
}


if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
    Help
fi

if [ -n "$1" ] ; then
  INFODIR="$1"
fi

if [ ! -d "$INFODIR" ] ; then
  echo "Not a directory: $INFODIR." >&2
  exit 1
fi

if [ -r "$INFODIR/dir" ] ; then
  rm -f "$INFODIR/dir.old"
  cp $INFODIR/dir $INFODIR/dir.old
fi

# we have to remove the dir file not make install-info being surprised
rm -f "$INFODIR/dir"

errors=0
find "$INFODIR" -type f | while read file ; do
  case $file in
    */dir|*/dir.gz|*/dir.old|*/dir.old.gz|*-[0-9]|*-[0-9].gz|*-[1-9][0-9]|*-[1-9][0-9].gz|*.png|*.jpg)
      # these files are ignored
      continue
      ;;
    *)
      install-info "$file" "$INFODIR/dir" || {
        errors=$((errors+1))
      }
      ;;
  esac
done

if [ $errors -gt 0 ] ; then
  exec >&2
  echo
  echo "Updating the index of info documentation produced $errors errors."
fi

exit 0

# vim:set expandtab tabstop=2: #
OpenPGP_signature.asc (application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE-----

wsF5BAABCAAjFiEEaXGmC/nkbIhxf16kxiZYRqvgLIsFAmmHaVwFAwAAAAAACgkQxiZYRqvgLIt3
Hw/+Id/V9dkPMx2I0EVONi4tbysqNV6pw5nwdTjBhDXVE+NW2sIHKj6UMJOXarbtohrgl+H7VP+2
u3KiuhJnEIvIPecsy+oGf+bRKMb9zyRhbG5z55ifRnb3l/P19nccJVrH22M/vm+z/Y4/imH3kz1k
DBE+PZspDmSG3aokElJ8v6mnB8cKG8ls6ZmcGDK0JEPqMNHqeLGbSadi/pIbdKceD5SaSmXc1nsR
DRcjA2FumphGXW9FFWayyuOGLQl5K5QYURy0OuehQxDRrRkVRoRccNqwG0J/rkOZJiluVJ39YDx8
J1wMrkl05N2szzm46xWQp7o/yrUe4CM3rEwmY5Um5eHuzI9xZLeUKuJnIWdMUNK6KyumyoI9Ri9P
h4uFMEN5O4rOFZa0cGwZ6ReOSxW9AdeGGP8d9Ei/Yk2hd5gS4L4fNT0V/+UDmIj7hiZNGeCPd1iq
24a2vKePpLkd4wvh5Sh92oangdzUvEVSq1NjLiUbd3KvmdNjQ8rPDLeSRjMqoqGu3TWNvMEcEgwZ
BUCA32Uz2avOUxwLJFnywzoNnZsxUy+5tycj+krIC4NDerectDKUcyY4WKgx+ZxGsPbe46AQSX+d
6diJRtJ+VUckWxHlrCzEovr8PKvFXOR16gigKEyAGF2ehIHjJZd/+bnsiQf4sYyNUvGJxYShEXKE
O6o=
=4kNX
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.