One of the reasons cd might fail is that the checkout of the webcvs
repository might fail because ${cvs_user} is incorrect.  In that
situation, the script will try to add the contents of the
current (build) directory to CVS.  This won't actually work (since
${cvs_user} is incorrect) but it generates a lot of confusing output.

* build-aux/gnu-web-doc-update: if cd fails, exit with a non-zero
status.  Quote some variable expansions.  Use find -exec where it is
simpler than xargs.  Remove unnecessary use of sed.
---
 build-aux/gnu-web-doc-update | 42 +++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/build-aux/gnu-web-doc-update b/build-aux/gnu-web-doc-update
index e4427a8b71..108c76ef20 100755
--- a/build-aux/gnu-web-doc-update
+++ b/build-aux/gnu-web-doc-update
@@ -2,7 +2,7 @@
 # Run this after each non-alpha release, to update the web documentation at
 # https://www.gnu.org/software/$pkg/manual/
 
-VERSION=2026-03-27.02; # UTC
+VERSION=2026-07-14.06; # UTC
 
 # Copyright (C) 2009-2026 Free Software Foundation, Inc.
 
@@ -19,7 +19,7 @@ VERSION=2026-03-27.02; # UTC
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-ME=$(basename "$0")
+ME="$( basename "$0" )"
 warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
 die() { warn "$*"; exit 1; }
 
@@ -140,11 +140,11 @@ test $# = 0 \
   || die "too many arguments"
 
 prev=.prev-version
-version=$(cat $prev) || die "no $prev file?"
-pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \
+version="$(cat "${prev}" )" || die "no $prev file?"
+pkg="$( sed -n 's/^PACKAGE = \(.*\)/\1/p' "${builddir}/Makefile" )" \
   || die "no Makefile?"
-tmp_branch=web-doc-$version-$$
-current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}')
+tmp_branch="web-doc-${version}-${$}"
+current_branch="$( $GIT branch | sed -ne '/^\* /{s///;p;q;}' )"
 
 cleanup()
 {
@@ -162,7 +162,7 @@ trap 'exit $?' HUP INT PIPE TERM
 # just-released version number, not some string like 7.6.18-20761.
 # That version string propagates into all documentation.
 set -e
-$GIT checkout -b $tmp_branch v$version
+$GIT checkout -b "${tmp_branch}" "v${version}"
 $GIT submodule update --recursive
 ./bootstrap
 srcdir=$(pwd)
@@ -175,39 +175,41 @@ builddir=$(pwd)
 cd "$srcdir"
 set +e
 
-tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1
-( cd $tmp \
-    && $CVS -d [email protected]:/webcvs/$pkg co $pkg )
+tmp="$( mktemp -d web-doc-update.XXXXXX )" || exit 1
+( cd "${tmp}" \
+    && $CVS -d [email protected]:/webcvs/$pkg co $pkg ) || exit 1
 $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
 
 (
-  cd $tmp/$pkg
+  cd "${tmp}/${pkg}" || exit 1
   test -d manual/CVS || $dryrun $CVS add -ko manual
 
-  cd manual
+  cd manual || exit 1
 
   # Add all the files.  This is simpler than trying to add only the
   # new ones because of new directories
   # First add non empty dirs individually
-  find . -name CVS -prune -o -type d \! -empty -print             \
-    | $XARGS -n1 --no-run-if-empty -- $dryrun $CVS add -ko
+  find . -name CVS -prune -o -type d \! -empty -exec $dryrun $CVS add -ko {} \;
   # Now add all files
-  find . -name CVS -prune -o -type f -print             \
-    | $XARGS --no-run-if-empty -- $dryrun $CVS add -ko
+  find . -name CVS -prune -o -type f -print -exec $dryrun $CVS add -ko {} +
 
   # Report/Remove stale files
   #   excluding doc server specific files like CVS/* and .symlinks
-  if test -n "$rm_stale"; then
+  if test -n "${rm_stale}"; then
     echo 'Consider the --mirror option if all of the manual is generated,' >&2
     echo 'which will run `cvs remove` to remove stale files.' >&2
   fi
-  { find . \( -name CVS -o -type f -name '.*' \) -prune -o -type f -print
-    (cd "$builddir"/doc/manual/ && find . -type f -print | sed p)
+
+  {
+      # Print the name of each file generated for the manual twice.
+      find "${builddir}/doc/manual" -type f -printf './%P\n./%P\n'
+      # Print the name of each file in the repository once.
+      find . \( -name CVS -o -type f -name '.*' \) -prune -o -type f -print
   } | sort | uniq -u \
     | $XARGS --no-run-if-empty -- ${rm_stale:-$dryrun} $CVS remove -f
 
   $dryrun $CVS ci -m $version
-)
+) || exit 1
 
 # Local variables:
 # eval: (add-hook 'before-save-hook 'time-stamp nil t)
-- 
2.47.3


Reply via email to