[tex-live] Bug#489943: texlive-base-bin: mktexpk does not work in directories containing spaces

Norbert Preining preining at logic.at
Tue Jul 8 23:24:00 CEST 2008


Hi Karl, hi all,

we got the following bug report with patch and detail analysis of
mktexpk failing under some circumstances.

Any comment?

On Di, 08 Jul 2008, Jan Hudec wrote:
> The mktexpk script fails if it tries to build a .pk in a directory with space
> (tested), tab or some backslash-character combinations (obvious from the
> code).
> 
> I traced the space problem down to a single cd with unquoted argument.
> However I also noticed use of echo+sed dirname replacement (with comment
> "can't rely on dirname" -- basename was relied on on the next line though),
> which would have problems with spaces at the end (backquote expansion eats
> them) and backslashes in some shells (the rules for backslash processing in
> echo differ from shell to shell). So my patch additionally includes
> a replacement of those two statements with ${var##pattern} and ${var%pattern}
> expansions. These expansions are POSIX and should thus be reasonably
> portable.
> 
> ##################################
> patch (standard patch -p1 unified diff)
> 
> --- old/build/source/texk/kpathsea/mktexpk	2006-01-17 22:41:51.000000000 +0100
> +++ new/build/source/texk/kpathsea/mktexpk	2008-07-08 21:49:14.000000000 +0200
> @@ -199,8 +199,8 @@
>  IFS=$OIFS
>  
>  PKDEST="$1"
> -PKDESTDIR=`echo "$PKDEST" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
> -PKNAME=`basename "$PKDEST"`
> +PKDESTDIR=${PKDEST%/*}
> +PKNAME=${PKDEST##*/}
>  GFNAME=$NAME.${DPI}gf
>  
>  if test -r "$PKDESTDIR/$PKNAME"; then
> @@ -250,7 +250,7 @@
>  # Use cp when mv fails, since DOS will fail mv for deeply-nested directories.
>  mv $PKNAME "$PKDESTDIR/pk$$.tmp" 2>/dev/null \
>    || cp $PKNAME "$PKDESTDIR/pk$$.tmp" || exit 1
> -cd $PKDESTDIR || exit 1
> +cd "$PKDESTDIR" || exit 1
>  chmod `kpsestat -xst,go-w .` pk$$.tmp
>  test -r $PKNAME || mv pk$$.tmp $PKNAME || exit 1

Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining at logic.at>        Vienna University of Technology
Debian Developer <preining at debian.org>                         Debian TeX Group
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
CROMARTY (n.)
The brittle sludge which clings to the top of ketchup bottles and
plastic tomatoes in nasty cafes.
			--- Douglas Adams, The Meaning of Liff


More information about the tex-live mailing list