finding locations of many files via kpse

Karl Berry karl at freefriends.org
Wed Jan 15 19:17:50 CET 2025


    Subject: Re: finding locations of many files via kpse

Returning to this thread from last July, starting at
https://tug.org/pipermail/texhax/2024-July/026506.html

I've just committed (r73462) a simple change to kpsewhich so that it
will output a blank line for files that are not found, if multiple input
files were specified. I figured if only one file is specified, the exit
status sufficed, and this way the output for the most common case is
unchanged.  This will be in TL25. For example:

$ kpsewhich plain.tex foobar plain.mf
/usr/local/texlive/2024/texmf-dist/tex/plain/base/plain.tex

/usr/local/texlive/2024/texmf-dist/metafont/base/plain.mf
$

By the way, it occurred to me that a low-tech way to match up multiple
possibly-missing input files with the output would be to look at the
basenames. This could also be used to handle --all. I could also change
the output format for --all when multiple files were specified to be
unambiguous, if there's any demand, but I got the impression that --all
doesn't matter.

Hope this helps. Let me know if something more/else should be done.
--thanks, karl.
 
--- kpsewhich.c	(revision 73459)
+++ kpsewhich.c	(working copy)
@@ -951,7 +956,14 @@
 
   /* Usual case: look up each given filename.  */
   for (; optind < argc; optind++) {
-    unfound += lookup (kpse, argv[optind]);
+    unsigned status = lookup (kpse, argv[optind]);
+    unfound += status;
+    if (status == 1 && optind + 1 < argc) {
+      /* If not found, and more than one input file is specified,
+         output blank line so the return strings can be matched
+         up with the input strings. */
+      puts ("");
+    }
   }
 
   if (interactive) {


More information about the texhax mailing list.