From b12124c3271cd5245124ffe48bc4cb80ada92191 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 22 Nov 2026 17:35:24 +0100 Subject: [PATCH] qual: Select 4-space indentation for the sh scripts. Configure beautysh with the style that is already predominant in the tree: 4 spaces per nesting level, hard tabs turned off (tool.beautysh: indent_size = 4, tab = false). Given a 4-column tab width, the mixed "\t + 4 spaces" lines align exactly with the 2-level space indent, which corroborates a 4-column indent unit. By leading-whitespace line counts across the scripts touched here, spaces dominate (237 lines) over tabs (198) and tab/space mixes (50). Status of each script before the reformat, counting non-blank lines that carry leading whitespace (sp = space-indented, tab = tab-indented, mix = tab + spaces on the same line): | File | sp | tab | mix | Remark | |------------------------------------|------|------|-----|---------------------------------------------| | cmd-or-msg | 2 | 0 | 0 | uniform spaces | | maybe-make-man | 8 | 8 | 8 | 4sp blocks + tab case-arms | | mkgitver | 15 | 5 | 3 | 4sp blocks + tab arms | | old_versions/build_static.sh | 39 | 0 | 0 | uniform spaces | | packaging/prep-auto-dir | 12 | 12 | 2 | 4sp blocks + tab case-arms | | packaging/smart-make | 14 | 2 | 0 | 4sp blocks + tab arms | | packaging/solaris/build_pkg.sh | 0 | 0 | 0 | flat | | prepare-source | 17 | 21 | 4 | 4sp blocks + tab case-arms | | rsync-ssl | 98 | 98 | 31 | 4sp blocks + tab case-arms | | rsync-web/backup.txt | 1 | 0 | 0 | flat, 1 six-space continuation line | | rsync-web/bin/badge-update | 0 | 0 | 0 | flat | | rsync-web/bin/upload | 3 | 0 | 0 | uniform spaces | | rsync-web/rsync-debug | 0 | 0 | 0 | flat | | support/deny-rsync | 3 | 0 | 0 | uniform spaces | | support/install_deps_ubuntu.sh | 0 | 0 | 0 | flat | | support/instant-rsyncd | 2 | 43 | 2 | uniform tabs, counted lines are heredoc content | | support/lsh.sh | 17 | 3 | 0 | 4sp blocks with tab shorthand | | support/rsync-no-vanished | 3 | 2 | 0 | 4sp blocks with tab shorthand | | support/rsync-slash-strip | 5 | 4 | 0 | 4sp blocks with tab shorthand | The tab-indented lines are mostly case-arm bodies (one tab per arm level, the old shorthand for a nesting step) and their nested continuation lines ("\t + 4 spaces"); the remaining tabs are single second-level bodies in lsh.sh, rsync-no-vanished, rsync-slash-strip and mkgitver. instant-rsyncd is the only script written fully in tabs; its leading whitespace is kept intact since it is internally consistent. --- maybe-make-man | 32 ++++++++-------- mkgitver | 16 ++++---- packaging/prep-auto-dir | 28 +++++++------- packaging/smart-make | 4 +- prepare-source | 58 ++++++++++++++-------------- support/instant-rsyncd | 80 +++++++++++++++++++-------------------- support/lsh.sh | 20 +++++----- support/rsync-no-vanished | 4 +- support/rsync-slash-strip | 8 ++-- 9 files changed, 125 insertions(+), 125 deletions(-) diff --git a/maybe-make-man b/maybe-make-man index c81cc8474..608fba9f7 100755 --- a/maybe-make-man +++ b/maybe-make-man @@ -13,23 +13,23 @@ force_flagfile="$srcdir/.md2man-force" if [ ! -f "$flagfile" ]; then # We test our smallest manpage just to see if the python setup works. if "$srcdir/md-convert" --test "$srcdir/rsync-ssl.1.md" >/dev/null 2>&1; then - touch "$flagfile" + touch "$flagfile" else - outname=$(basename "$inname" .md) - if [ -f "$outname" ]; then - exit 0 - elif [ -f "$srcdir/$outname" ]; then - echo "Copying $srcdir/$outname" - cp -p "$srcdir/$outname" . - exit 0 - else - echo "ERROR: $outname cannot be created." - if [ -f "$HOME/build_farm/build_test.fns" ]; then - exit 0 # No exit errorno to avoid a build failure in the samba build farm - else - exit 1 - fi - fi + outname=$(basename "$inname" .md) + if [ -f "$outname" ]; then + exit 0 + elif [ -f "$srcdir/$outname" ]; then + echo "Copying $srcdir/$outname" + cp -p "$srcdir/$outname" . + exit 0 + else + echo "ERROR: $outname cannot be created." + if [ -f "$HOME/build_farm/build_test.fns" ]; then + exit 0 # No exit errorno to avoid a build failure in the samba build farm + else + exit 1 + fi + fi fi fi diff --git a/mkgitver b/mkgitver index 60b946811..ece80d6c3 100755 --- a/mkgitver +++ b/mkgitver @@ -20,13 +20,13 @@ if test -d "$srcdir/.git" || test -f "$srcdir/.git"; then # quoted value. Empty (define missing/unmatched) -> leave RSYNC_GITVER unset. rsyncver=$(sed -n 's/^[[:space:]]*#[[:space:]]*define[[:space:]][[:space:]]*RSYNC_VERSION[[:space:]][[:space:]]*"\([^"]*\)".*/\1/p' "$srcdir/version.h") if [ -n "$gitsha" ] && [ -n "$rsyncver" ]; then - gitver="$rsyncver-g$gitsha" - echo "#define RSYNC_GITVER \"$gitver\"" >git-version.h.new - if ! diff git-version.h.new git-version.h >/dev/null; then - echo "Updating git-version.h" - mv git-version.h.new git-version.h - else - rm git-version.h.new - fi + gitver="$rsyncver-g$gitsha" + echo "#define RSYNC_GITVER \"$gitver\"" >git-version.h.new + if ! diff git-version.h.new git-version.h >/dev/null; then + echo "Updating git-version.h" + mv git-version.h.new git-version.h + else + rm git-version.h.new + fi fi fi diff --git a/packaging/prep-auto-dir b/packaging/prep-auto-dir index 94ddc0a6c..a73cd9223 100755 --- a/packaging/prep-auto-dir +++ b/packaging/prep-auto-dir @@ -16,28 +16,28 @@ auto_top='auto-build-save' if test -d $auto_top && test -d .git; then desired_branch=$(git rev-parse --abbrev-ref HEAD | tr / %) if test "$desired_branch" = HEAD; then - echo "ERROR: switch to the right build dir manually when in detached HEAD mode." 1>&2 - exit 1 + echo "ERROR: switch to the right build dir manually when in detached HEAD mode." 1>&2 + exit 1 fi auto_dir="$auto_top/$desired_branch" if test -d build; then - cur_branch=$(readlink build/.branch) + cur_branch=$(readlink build/.branch) else - cur_branch='/' + cur_branch='/' fi if test "$desired_branch" != "$cur_branch"; then - if test "$cur_branch" != /; then - rm -f "$auto_top/$cur_branch" - mv build "$auto_top/$cur_branch" - fi - test -d "$auto_dir" || mkdir "$auto_dir" - test -h "$auto_dir/.branch" || ln -s "$desired_branch" "$auto_dir/.branch" - mv "$auto_dir" build - ln -s ../build "$auto_dir" + if test "$cur_branch" != /; then + rm -f "$auto_top/$cur_branch" + mv build "$auto_top/$cur_branch" + fi + test -d "$auto_dir" || mkdir "$auto_dir" + test -h "$auto_dir/.branch" || ln -s "$desired_branch" "$auto_dir/.branch" + mv "$auto_dir" build + ln -s ../build "$auto_dir" fi if test ! -h Makefile; then - rm -f Makefile - ln -s packaging/auto-Makefile Makefile + rm -f Makefile + ln -s packaging/auto-Makefile Makefile fi echo "$desired_branch" fi diff --git a/packaging/smart-make b/packaging/smart-make index 885185c28..1bea7896a 100755 --- a/packaging/smart-make +++ b/packaging/smart-make @@ -30,9 +30,9 @@ if diff configure.sh configure.sh.old >/dev/null 2>&1; then else echo "configure.sh has CHANGED." if test -f config.status; then - ./config.status --recheck + ./config.status --recheck else - $srcdir/configure + $srcdir/configure fi fi diff --git a/prepare-source b/prepare-source index c12efdcf7..7683c5bd3 100755 --- a/prepare-source +++ b/prepare-source @@ -19,20 +19,20 @@ fi if test "$dir" = '.'; then branch=$(packaging/prep-auto-dir) || exit 1 if test "$branch" != ""; then - cd build || exit 1 - dir=.. + cd build || exit 1 + dir=.. fi fi if test "$dir" != '.'; then for lnk in configure.ac m4; do - if test ! -h $lnk; then - rm -f $lnk # Just in case - ln -s "$dir/$lnk" $lnk - fi + if test ! -h $lnk; then + rm -f $lnk # Just in case + ln -s "$dir/$lnk" $lnk + fi done for fn in configure.sh config.h.in aclocal.m4; do - test ! -f $fn && test -f "$dir/$fn" && cp -p "$dir/$fn" $fn + test ! -f $fn && test -f "$dir/$fn" && cp -p "$dir/$fn" $fn done fi @@ -42,30 +42,30 @@ fi for action in "${@}"; do case "$action" in - build|make) - make -f "$dir/prepare-source.mak" - ;; - fetch|fetchgen) - if test "$action" = fetchgen; then - match='*' - else - match='[ca]*' - fi - "$dir"/rsync-ssl -iipc --no-motd "rsync://download.samba.org/rsyncftp/generated-files/$match" ./ - test $? != 0 && continue - sleep 1 # The following files need to be newer than aclocal.m4 - touch configure.sh config.h.in - ;; - fetchSRC) - ./rsync-ssl -iipr --no-motd --exclude=/.git/ rsync://download.samba.org/ftp/pub/unpacked/rsync/ . - ;; - *) - echo "Unknown action: $action" - exit 1 - ;; + build|make) + make -f "$dir/prepare-source.mak" + ;; + fetch|fetchgen) + if test "$action" = fetchgen; then + match='*' + else + match='[ca]*' + fi + "$dir"/rsync-ssl -iipc --no-motd "rsync://download.samba.org/rsyncftp/generated-files/$match" ./ + test $? != 0 && continue + sleep 1 # The following files need to be newer than aclocal.m4 + touch configure.sh config.h.in + ;; + fetchSRC) + ./rsync-ssl -iipr --no-motd --exclude=/.git/ rsync://download.samba.org/ftp/pub/unpacked/rsync/ . + ;; + *) + echo "Unknown action: $action" + exit 1 + ;; esac if test $? = 0; then - exit + exit fi done diff --git a/support/instant-rsyncd b/support/instant-rsyncd index 1a505a5f2..3641151ae 100755 --- a/support/instant-rsyncd +++ b/support/instant-rsyncd @@ -20,31 +20,31 @@ echo echo "This will setup an rsync daemon in $dir" if [ $# = 0 ]; then - IFS='' read -r -p 'Module name to create (or return to exit): ' module - [ ! "$module" ] && exit + IFS='' read -r -p 'Module name to create (or return to exit): ' module + [ ! "$module" ] && exit else - module="$1" - shift + module="$1" + shift fi if [ $# = 0 ]; then - IFS='' read -r -p 'Port number the daemon should listen on [873]: ' port + IFS='' read -r -p 'Port number the daemon should listen on [873]: ' port else - port="$1" - shift + port="$1" + shift fi [ "$port" ] || port=873 if [ $# = 0 ]; then - IFS='' read -r -p 'User name for authentication (empty for none): ' user + IFS='' read -r -p 'User name for authentication (empty for none): ' user else - user="$1" - shift + user="$1" + shift fi if [ "$user" ]; then - IFS='' read -r -s -p 'Desired password: ' password - echo + IFS='' read -r -s -p 'Desired password: ' password + echo fi rsync="$1" @@ -66,14 +66,14 @@ use chroot = no EOF if [ "$user" ]; then - cat >>rsyncd.conf <<-EOF + cat >>rsyncd.conf <<-EOF auth users = $user secrets file = $module.secrets EOF - touch "$module".secrets - chmod go-rwx "$module".secrets - echo "$user:$password" >"$module".secrets - user="$user@" + touch "$module".secrets + chmod go-rwx "$module".secrets + echo "$user:$password" >"$module".secrets + user="$user@" fi cat >start <&2; exit 1 ;; + -l) user="$2"; shift; shift ;; + -l*) user=$(echo "$1" | sed 's/^-l//'); shift ;; + --no-cd) do_cd=n; shift ;; + -*) shift ;; + localhost) shift; break ;; + lh) do_cd=n; shift; break ;; + *) echo "lsh: unable to connect to host $1" 1>&2; exit 1 ;; esac done if [ "$user" ]; then prefix='' if [ $do_cd = y ]; then - home=$(perl -e "print((getpwnam('$user'))[7])") - prefix="cd '$home' &&" + home=$(perl -e "print((getpwnam('$user'))[7])") + prefix="cd '$home' &&" fi sudo -H -u "$user" sh -c "$prefix $*" else if [ $do_cd = y ]; then - cd || exit 1 + cd || exit 1 fi # shellcheck disable=2294 eval "${@}" diff --git a/support/rsync-no-vanished b/support/rsync-no-vanished index f14351ac4..8b3fe3da2 100755 --- a/support/rsync-no-vanished +++ b/support/rsync-no-vanished @@ -7,8 +7,8 @@ IGNOREOUT='^((file|directory) has vanished: |rsync warning: some files vanished # If someone installs this as "rsync", make sure we don't affect a server run. for arg in "${@}"; do if [[ "$arg" == --server ]]; then - exec $REAL_RSYNC "${@}" - exit $? # Not reached + exec $REAL_RSYNC "${@}" + exit $? # Not reached fi done diff --git a/support/rsync-slash-strip b/support/rsync-slash-strip index b57e61c53..dff2f3a37 100755 --- a/support/rsync-slash-strip +++ b/support/rsync-slash-strip @@ -12,13 +12,13 @@ REAL_RSYNC=/usr/bin/rsync args=() for arg in "${@}"; do if [[ "$arg" == --server ]]; then - exec $REAL_RSYNC "${@}" - exit $? # Not reached + exec $REAL_RSYNC "${@}" + exit $? # Not reached fi if [[ "$arg" == / ]]; then - args=("${args[@]}" /) + args=("${args[@]}" /) else - args=("${args[@]}" "${arg%/}") + args=("${args[@]}" "${arg%/}") fi done exec $REAL_RSYNC "${args[@]}"