bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] gnulib-tool: Don't assume writable source


From: Benno Fünfstück
Subject: [PATCH] gnulib-tool: Don't assume writable source
Date: Tue, 18 Feb 2020 21:20:49 +0100

If the location in which gnulib-tool is installed is not writable (the
files are readonly), then cp'ing those files creates readonly files as
well. To avoid this, use `cat $foo > $bar` to create a new file, with
fresh attributes.
---
 gnulib-tool | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/gnulib-tool b/gnulib-tool
index 89f6077e5..158873d4f 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -1715,8 +1715,7 @@ func_lookup_file ()
   lookedup_tmp=
   if test -n "$lkpatches"; then
     lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
-    rm -f "$tmp/$lkbase"
-    cp "$lookedup_file" "$tmp/$lkbase"
+    cat "$lookedup_file" > "$tmp/$lkbase"
     save_IFS="$IFS"
     IFS="$PATH_SEPARATOR"
     for patchfile in $lkpatches; do
@@ -5224,7 +5223,7 @@ s,^\(.................................................[^ 
]*\) *,
     esac
     func_dest_tmpfilename "$g"
     func_lookup_file "$f"
-    cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
+    cat "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
     case "$f" in
       *.class | *.mo )
         # Don't process binary files with sed.
@@ -7316,7 +7315,7 @@ s/\([.*$]\)/[\1]/g'
     fi
     # Copy the file.
     func_dest_tmpfilename "$g"
-    cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
+    cat "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
     already_present=true
     if test -f "$destdir/$g"; then
       # The file already exists.
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]