savannah-cvs
[Top][All Lists]
Advanced

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

[Savannah-cvs] [738] fixup copyright header function


From: iank
Subject: [Savannah-cvs] [738] fixup copyright header function
Date: Wed, 3 Jan 2024 06:39:35 -0500 (EST)

Revision: 738
          
http://svn.savannah.gnu.org/viewvc/?view=rev&root=administration&revision=738
Author:   iank
Date:     2024-01-03 06:39:34 -0500 (Wed, 03 Jan 2024)
Log Message:
-----------
fixup copyright header function

Modified Paths:
--------------
    trunk/sviki/fsf.mdwn

Modified: trunk/sviki/fsf.mdwn
===================================================================
--- trunk/sviki/fsf.mdwn        2024-01-03 10:34:13 UTC (rev 737)
+++ trunk/sviki/fsf.mdwn        2024-01-03 11:39:34 UTC (rev 738)
@@ -86,17 +86,22 @@
 # Function to add standard copyright header to file, easier than
 # copy/pasting. If you copy this and don't work for FSF, change the
 # copyright holder to you or your employer depending on your situation.
-
 fsf-sv-header() {
-local f
-if ! type -p sponge &>/dev/null; then
-  echo "$0: error: missing dependency: sudo apt install moreutils" >&2
-  return 1
-fi
+  local f
+  local -a f_maybe
+  if ! type -p sponge &>/dev/null; then
+    echo "$0: error: missing dependency: sudo apt install moreutils" >&2
+    return 1
+  fi
 
-for f; do
-  echo "adding header to $f"
-  cat <<EOF | sponge "$f"
+  for f; do
+    echo "adding header to $f"
+    if [[ -s $f ]]; then
+      f_maybe=("$f")
+    else
+      f_maybe=()
+    fi
+    cat - "${f_maybe[@]}" <<EOF | sponge "$f"
 The following is the GNU All-permissive License as recommended in
 <https://www.gnu.org/licenses/license-recommendations.en.html>
 
@@ -110,7 +115,7 @@
 Contributions are welcome. See <https://savannah.gnu.org/maintenance/fsf/>.
 
 EOF
-done
+  done
 }
 ```
 




reply via email to

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