[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fonts in user home



Frank Küster <frank@debian.org> wrote:

> shouldn't that be 
>
>          echo "$(basename "$file")/$(dirname "$file")"
>
> according to your description? 

No: the slash separating both parts comes from dirname's output. That
would get you two slashes in a row. I am attaching a patch that adds
comments about handle_file and merge_files (which was planned when I
wrote the script, but forgot :-).
--- update-updmap.orig	2005-06-22 00:20:35.000000000 +0200
+++ update-updmap	2005-06-22 00:24:25.000000000 +0200
@@ -87,6 +87,12 @@
     done
 }
 
+# handle_file <file path>
+#
+# <file path> must point to an update-updmap configuration file (such as
+# /etc/texmf/updmap.d/05tetex-extra.cfg). The function decides whether the file
+# should be included in $output_file and outputs the corresponding snippet if
+# yes, or a comment explaining why if no.
 handle_file()
 {
     file="$1"
@@ -107,10 +113,40 @@
     fi
 }
 
+# merge_files
+#
+# This function expects on the standard input a sorted list of update-updmap
+# configuration files (such as /etc/texmf/updmap.d/05tetex-extra.cfg). Each of
+# them should be listed on a line by itself with the basename being the
+# *first* component of the path, e.g.:
+#
+#   05tetex-extra.cfg/etc/texmf/updmap.d
+#
+# (where 05 should be at the beginning of the line, with no leading spaces, of
+# course). This is so because the sort operation presumably performed by the
+# caller of this function should sort on the basenames of the files,
+# regardless of the directories they come from.
+#
+# Since the list is expected to be sorted, if several files have the same
+# basename, they will be found on consecutive lines.
+#
+# The function calls handle_file() for every file in the list, but only once
+# for a single basename. If several files with the same basename are listed
+# from several directories, only the one in $conf_dir will be passed to
+# handle_file. This allows user-defined .cfg files to override system .cfg
+# files (those in /etc). The order of the files is preserved:
+# handle_file() will receive them as they came on stdin, except that it will
+# be called only once for each basename.
+#
+# handle_file receives the file path in the usual order (directory/basename).
 merge_files()
 {
+    # We will procede the list focusing on the last two elements in order to
+    # handle the case of several files in a row having the same basename.
     lastfile=""
     lastdir=""
+    # Overloaded files are files with the same basename that were found in
+    # several directories.
     overloaded=0
 
     while read line; do
@@ -118,8 +154,7 @@
         dirname="/${line#*/}"
         if [ -n "$lastfile" ]; then
             if [ "$lastfile" != "$filename" ]; then
-                # For overloaded files (two .cfg files with the same basename),
-                # use the one in $conf_dir.
+                # For overloaded files, use the one in $conf_dir.
                 if [ $overloaded = 1 ]; then
                     overloaded=0
                     dir="$conf_dir"
@@ -137,7 +172,7 @@
 
     # Test whether there was at least one line to read from stdin
     if [ -n "$lastdir" ]; then
-    # The last file is still in the pipe; get it out.
+        # The last file is still in the pipe; get it out.
         if [ $overloaded = 1 ]; then
             dir="$conf_dir"
         else
@@ -301,7 +336,7 @@
 
 # Creating the temporary file in the output directory gives it automatically
 # the default permissions appropriate for that directory, according to the
-# user's umaks. When it is complete, we'll be able to rename it atomically to
+# user's umask. When it is complete, we'll be able to rename it atomically to
 # the desired output file, which will therefore have the right permissions.
 tempfile="${output_file}.new"
 
-- 
Florent

Reply to: