[tex-k] ls -R
Olaf Weber
olaf at infovore.xs4all.nl
Fri Oct 24 11:07:48 CEST 2003
Reinhard Kotucha writes:
> Hi,
> under the assumption that UNIX claims that the output of one program
> can be processed by an other, there is probably a bug in UNIX's ls
> command which has some impact on web2c based TeX systems.
> If you want to have some fun, just type:
> touch `kpsewhich -expand-var=\\$TEXMFMAIN`/fonts/tfm/public/cm/a:
> texhash
> ...and your TeX system is broken.
Ouch.
> ls -R appends a colon to each directory. Unfortunately, a colon is a
> valid character in filenames. The only character which is disallowed
> in filenames is a slash. So the slash is the only character which can
> mark a directory reliably as a directory.
Unfortunately there are version of ls which will not prepend the './',
which confuses kpathsea -- hence the munging of the ls output in
mktexlsr.
> The problem is quite nasty because the user who accidentally installs
> a file which ends with a colon doesn't get any error message at all.
> It is extremely hard to locate the bug.
Assuming we can rely on 'ls' inserting an empty line before each
directory (e.g, filenames with newlines in them _will_ break things)
and that we can rely on 'sed' not being completely hopeless, the
following should fix this. I would really like to know if for some
reason this cannot be used.
$ cvs diff -u mktexlsr
Index: mktexlsr
===================================================================
RCS file: /usr/local/cvsroot/texk/texk/kpathsea/mktexlsr,v
retrieving revision 1.32
diff -u -r1.32 mktexlsr
--- mktexlsr 22 Oct 2002 18:34:07 -0000 1.32
+++ mktexlsr 24 Oct 2003 08:05:51 -0000
@@ -111,7 +111,7 @@
# names results in nothing but grief.
echo "./:" >>"$db_file_tmp"
(cd "$TEXMFLS_R" && \ls -LRa 2>/dev/null) |
- sed 's%^[^.].*:$%./&%; /^\.$/d; /^\.\.$/d; /^lsR[0-9]*\.tmp$/d' >>"$db_file_tmp"
+ sed '/^$/{n;s%^\./%%;s%^%./%}; /^\.$/d; /^\.\.$/d; /^lsR[0-9]*\.tmp$/d' >>"$db_file_tmp"
# To be really safe, a loop.
until PERMS=`kpsestat = "$db_file"`; do sleep 1; done
--
Olaf Weber
(This space left blank for technical reasons.)
More information about the tex-k
mailing list