diff --git a/cmd-or-msg b/cmd-or-msg index ccf9527f9..48dffef09 100755 --- a/cmd-or-msg +++ b/cmd-or-msg @@ -1,11 +1,11 @@ #!/bin/sh -srcdir=`dirname $0` +srcdir=$(dirname "$0") opt="$1" shift echo "$*" if ! "${@}"; then - echo "If you can't fix the issue, re-run $srcdir/configure with --$opt." + echo "If you can't fix the issue, re-run ${srcdir}/configure with --${opt}." exit 1 fi diff --git a/configure b/configure index 51c3fee58..8238141d7 100755 --- a/configure +++ b/configure @@ -3,14 +3,14 @@ # if not, it tries to fetch rsync's generated files or build them. We # then transfer control to the configure.sh script to do the real work. -dir=`dirname $0` -if test x"$dir" = x; then +dir=$(dirname "$0") +if test "$dir" = ""; then dir=. fi if test "$dir" = '.'; then - branch=`packaging/prep-auto-dir` || exit 1 - if test x"$branch" != x; then + branch=$(packaging/prep-auto-dir) || exit 1 + if test "$branch" != ""; then cd build || exit 1 dir=.. fi diff --git a/install-sh b/install-sh index 8c409fbb9..2387cdcca 100755 --- a/install-sh +++ b/install-sh @@ -10,6 +10,7 @@ # This script is compatible with the BSD install script, but was written # from scratch. # +# shellcheck disable=2086 # set DOITPROG to echo to test this script @@ -30,7 +31,7 @@ rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" -transform_arg="" +transformarg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" @@ -42,7 +43,7 @@ src="" dst="" dir_arg="" -while [ x"$1" != x ]; do +while [ "$1" != "" ]; do case $1 in -c) instcmd="$cpprog" shift @@ -71,15 +72,15 @@ while [ x"$1" != x ]; do shift continue;; - -t=*) transformarg=`echo $1 | sed 's/-t=//'` + -t=*) transformarg=$(echo "$1" | sed 's/-t=//') shift continue;; - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + -b=*) transformbasename=$(echo "$1" | sed 's/-b=//') shift continue;; - *) if [ x"$src" = x ] + *) if [ "$src" = "" ] then src=$1 else @@ -92,7 +93,7 @@ while [ x"$1" != x ]; do esac done -if [ x"$src" = x ] +if [ "$src" = "" ] then echo "install: no input file specified" exit 1 @@ -100,14 +101,14 @@ else true fi -if [ x"$dir_arg" != x ]; then - dst=$src +if [ "$dir_arg" != "" ]; then + dst="$src" src="" - if [ -d $dst ]; then - instcmd=: + if [ -d "$dst" ]; then + instcmd=":" else - instcmd=mkdir + instcmd="mkdir" fi else @@ -115,7 +116,7 @@ else # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. - if [ -f $src ] || [ -d $src ] + if [ -f "$src" ] || [ -d "$src" ] then true else @@ -123,7 +124,7 @@ else exit 1 fi - if [ x"$dst" = x ] + if [ "$dst" = "" ] then echo "install: no destination specified" exit 1 @@ -134,16 +135,16 @@ else # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic - if [ -d $dst ] + if [ -d "$dst" ] then - dst="$dst"/`basename $src` + dst="$dst"/$(basename "$src") else true fi fi ## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` +dstdir=$(echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,') # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script @@ -157,7 +158,8 @@ IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +# shellcheck disable=2046 +set - $(echo "${dstdir}" | sed -e 's@/@%@g' -e 's@^%@/@') IFS="${oIFS}" pathcomp='' @@ -177,31 +179,30 @@ while [ $# -ne 0 ] ; do done fi -if [ x"$dir_arg" != x ] +if [ "$dir_arg" != "" ] then - $doit $instcmd $dst && + $doit $instcmd "$dst" && - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi + if [ "$chowncmd" != "" ]; then $doit $chowncmd "$dst"; else true ; fi && + if [ "$chgrpcmd" != "" ]; then $doit $chgrpcmd "$dst"; else true ; fi && + if [ "$stripcmd" != "" ]; then $doit $stripcmd "$dst"; else true ; fi && + if [ "$chmodcmd" != "" ]; then $doit $chmodcmd "$dst"; else true ; fi else # If we're going to rename the final executable, determine the name now. - if [ x"$transformarg" = x ] + if [ "$transformarg" = "" ] then - dstfile=`basename $dst` + dstfile=$(basename "$dst") else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename + dstfile=$(basename "$dst" "$transformbasename" | sed "$transformarg")"$transformbasename" fi # don't allow the sed command to completely eliminate the filename - if [ x"$dstfile" = x ] + if [ "$dstfile" = "" ] then - dstfile=`basename $dst` + dstfile=$(basename "$dst") else true fi @@ -212,9 +213,9 @@ else # Move or copy the file name to the temp name - $doit $instcmd $src $dsttmp && + $doit $instcmd "$src" "$dsttmp" && - trap "rm -f ${dsttmp}" 0 && + trap 'rm -f "${dsttmp}"' 0 && # and set any options; do chmod last to preserve setuid bits @@ -222,15 +223,15 @@ else # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + if [ "$chowncmd" != "" ]; then $doit $chowncmd "$dsttmp"; else true;fi && + if [ "$chgrpcmd" != "" ]; then $doit $chgrpcmd "$dsttmp"; else true;fi && + if [ "$stripcmd" != "" ]; then $doit $stripcmd "$dsttmp"; else true;fi && + if [ "$chmodcmd" != "" ]; then $doit $chmodcmd "$dsttmp"; else true;fi && # Now rename the file to the real destination. - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile + $doit $rmcmd -f "$dstdir"/"$dstfile" && + $doit $mvcmd "$dsttmp" "$dstdir"/"$dstfile" fi && diff --git a/maybe-make-man b/maybe-make-man index b751ebc53..c81cc8474 100755 --- a/maybe-make-man +++ b/maybe-make-man @@ -6,16 +6,16 @@ if [ $# != 1 ]; then fi inname="$1" -srcdir=`dirname "$0"` +srcdir=$(dirname "$0") flagfile="$srcdir/.md2man-works" 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` + outname=$(basename "$inname" .md) if [ -f "$outname" ]; then exit 0 elif [ -f "$srcdir/$outname" ]; then diff --git a/mkgitver b/mkgitver index 8417ff808..60b946811 100755 --- a/mkgitver +++ b/mkgitver @@ -1,6 +1,6 @@ #!/bin/sh -srcdir=`dirname $0` +srcdir=$(dirname "$0") if [ ! -f git-version.h ]; then touch git-version.h @@ -15,10 +15,10 @@ if test -d "$srcdir/.git" || test -f "$srcdir/.git"; then # clone. A release tarball has no .git, so git-version.h stays empty and # rsync prints the plain RSYNC_VERSION. # cd into the subshell rather than "git -C" (avoids needing a newer git). - gitsha=`(cd "$srcdir" && git rev-parse --short=8 HEAD) 2>/dev/null` + gitsha=$(cd "$srcdir" && git rev-parse --short=8 HEAD 2>/dev/null) # Tolerate any preprocessor spacing and a trailing comment; capture only the # 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"` + 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 diff --git a/packaging/prep-auto-dir b/packaging/prep-auto-dir index b67f390ab..94ddc0a6c 100755 --- a/packaging/prep-auto-dir +++ b/packaging/prep-auto-dir @@ -14,14 +14,14 @@ auto_top='auto-build-save' if test -d $auto_top && test -d .git; then - desired_branch=`git rev-parse --abbrev-ref HEAD | tr / %` + 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 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='/' fi @@ -39,5 +39,5 @@ if test -d $auto_top && test -d .git; then rm -f Makefile ln -s packaging/auto-Makefile Makefile fi - echo $desired_branch + echo "$desired_branch" fi diff --git a/packaging/smart-make b/packaging/smart-make index 9da044262..885185c28 100755 --- a/packaging/smart-make +++ b/packaging/smart-make @@ -4,8 +4,8 @@ set -e export LANG=C -branch=`packaging/prep-auto-dir` -if test x"$branch" = x; then +branch=$(packaging/prep-auto-dir) +if test "$branch" = ""; then srcdir=. else cd build @@ -40,6 +40,6 @@ fi make all -if test x"$1" = x"check"; then +if test "$1" = "check"; then make check fi diff --git a/packaging/solaris/build_pkg.sh b/packaging/solaris/build_pkg.sh index 29c035a09..1d0450b56 100755 --- a/packaging/solaris/build_pkg.sh +++ b/packaging/solaris/build_pkg.sh @@ -20,7 +20,7 @@ PKGNAME=SMBrsync # but for now it is hard coded BASEDIR=/usr/local VERSION="2.5.5" -ARCH=`uname -p` +ARCH=$(uname -p) NAME=rsync # Definitions end here @@ -28,27 +28,27 @@ NAME=rsync ## Start by faking root install echo "Creating install directory (fake $BASEDIR)..." -START=`pwd` -FAKE_ROOT=$START/${PKGNAME} -mkdir $FAKE_ROOT +START=$(pwd) +FAKE_ROOT="$START"/"${PKGNAME}" +mkdir "$FAKE_ROOT" # copy the binary and the man page to their places -mkdir $FAKE_ROOT/bin -mkdir -p $FAKE_ROOT/doc/rsync -mkdir -p $FAKE_ROOT/man/man1 -mkdir -p $FAKE_ROOT/man/man5 +mkdir "$FAKE_ROOT"/bin +mkdir -p "$FAKE_ROOT"/doc/rsync +mkdir -p "$FAKE_ROOT"/man/man1 +mkdir -p "$FAKE_ROOT"/man/man5 -cp ../../../rsync $FAKE_ROOT/bin/rsync -cp ../../../rsync.1 $FAKE_ROOT/man/man1/rsync.1 -cp ../../../rsyncd.conf.5 $FAKE_ROOT/man/man5/rsyncd.conf.5 -cp ../../../README.md $FAKE_ROOT/doc/rsync/README.md -cp ../../../COPYING $FAKE_ROOT/doc/rsync/COPYING -cp ../../../tech_report.pdf $FAKE_ROOT/doc/rsync/tech_report.pdf -cp ../../../COPYING $FAKE_ROOT/COPYING +cp ../../../rsync "$FAKE_ROOT"/bin/rsync +cp ../../../rsync.1 "$FAKE_ROOT"/man/man1/rsync.1 +cp ../../../rsyncd.conf.5 "$FAKE_ROOT"/man/man5/rsyncd.conf.5 +cp ../../../README.md "$FAKE_ROOT"/doc/rsync/README.md +cp ../../../COPYING "$FAKE_ROOT"/doc/rsync/COPYING +cp ../../../tech_report.pdf "$FAKE_ROOT"/doc/rsync/tech_report.pdf +cp ../../../COPYING "$FAKE_ROOT"/COPYING ## Build info file echo "Building pkginfo file..." -cat > $FAKE_ROOT/pkginfo << EOF_INFO +cat > "$FAKE_ROOT"/pkginfo << EOF_INFO PKG=$PKGNAME NAME=$NAME DESC="Program for efficient remote updates of files." @@ -61,7 +61,7 @@ CLASSES=none EOF_INFO ## Build prototype file -cat > $FAKE_ROOT/prototype << EOFPROTO +cat > "$FAKE_ROOT"/prototype << EOFPROTO i copyright=COPYING i pkginfo=pkginfo d none bin 0755 bin bin @@ -81,14 +81,13 @@ EOFPROTO ## And now build the package. OUTPUTFILE=$PKGNAME-$VERSION-sol8-$ARCH-local.pkg echo "Building package.." -echo FAKE_ROOT = $FAKE_ROOT -cd $FAKE_ROOT +echo "FAKE_ROOT = $FAKE_ROOT" +cd "$FAKE_ROOT" || exit pkgmk -d . -r . -f ./prototype -o -pkgtrans -os . $OUTPUTFILE $PKGNAME +pkgtrans -os . "$OUTPUTFILE" "$PKGNAME" -mv $OUTPUTFILE .. -cd .. +mv "$OUTPUTFILE" .. +cd .. || exit # Comment this out if you want to see, which file structure has been created -rm -rf $FAKE_ROOT - +rm -rf "$FAKE_ROOT" diff --git a/prepare-source b/prepare-source index a4e78e61e..c12efdcf7 100755 --- a/prepare-source +++ b/prepare-source @@ -11,14 +11,14 @@ # # The script stops after the first successful action. -dir=`dirname $0` -if test x"$dir" = x; then +dir=$(dirname "$0") +if test "$dir" = ""; then dir=. fi if test "$dir" = '.'; then - branch=`packaging/prep-auto-dir` || exit 1 - if test x"$branch" != x; then + branch=$(packaging/prep-auto-dir) || exit 1 + if test "$branch" != ""; then cd build || exit 1 dir=.. fi @@ -51,7 +51,7 @@ for action in "${@}"; do else match='[ca]*' fi - $dir/rsync-ssl -iipc --no-motd "rsync://download.samba.org/rsyncftp/generated-files/$match" ./ + "$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 diff --git a/rsync-web/bin/badge-update b/rsync-web/bin/badge-update index 2b5b72ad8..bda0b8c22 100755 --- a/rsync-web/bin/badge-update +++ b/rsync-web/bin/badge-update @@ -1,4 +1,4 @@ #!/bin/sh rm -f badge.svg wget https://github.com/RsyncProject/rsync/workflows/build/badge.svg -rsync -aiic --inplace --remove-source-files badge.svg $SAMBA_HOST:/home/httpd/html/rsync/ +rsync -aiic --inplace --remove-source-files badge.svg "$SAMBA_HOST":/home/httpd/html/rsync/ diff --git a/rsync-web/bin/upload b/rsync-web/bin/upload index 39bae3e50..295326115 100755 --- a/rsync-web/bin/upload +++ b/rsync-web/bin/upload @@ -1,6 +1,6 @@ #!/bin/sh if [ -d rsync-and-debian ]; then - rsync -aviOHFFc --del -f._filt . $SAMBA_HOST:/home/httpd/html/rsync/ "${@}" + rsync -aviOHFFc --del -f._filt . "$SAMBA_HOST":/home/httpd/html/rsync/ "${@}" else echo "Run this from the root of the html hierarchy." exit 1 diff --git a/rsync-web/rsync-debug b/rsync-web/rsync-debug index adb6ee5f9..662ccd2ab 100755 --- a/rsync-web/rsync-debug +++ b/rsync-web/rsync-debug @@ -1,5 +1,6 @@ #!/bin/sh +# shellcheck disable=3045 ulimit -c unlimited # Some systems have "truss" or "tusc" instead of "strace". diff --git a/support/deny-rsync b/support/deny-rsync index bd4da9e73..78cf0459c 100755 --- a/support/deny-rsync +++ b/support/deny-rsync @@ -8,7 +8,7 @@ exit_code=4 # same as a daemon that refuses an option # e.g. byte_escape 29 => \035 function byte_escape { - echo -ne "\\0$(printf "%o" $1)" + echo -ne "\\0$(printf "%o" "$1")" } msg="$1" diff --git a/support/instant-rsyncd b/support/instant-rsyncd index 8bcfd0018..1a505a5f2 100755 --- a/support/instant-rsyncd +++ b/support/instant-rsyncd @@ -20,7 +20,7 @@ echo echo "This will setup an rsync daemon in $dir" if [ $# = 0 ]; then - IFS='' read -p 'Module name to create (or return to exit): ' module + IFS='' read -r -p 'Module name to create (or return to exit): ' module [ ! "$module" ] && exit else module="$1" @@ -28,7 +28,7 @@ else fi if [ $# = 0 ]; then - IFS='' read -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 @@ -36,14 +36,14 @@ fi [ "$port" ] || port=873 if [ $# = 0 ]; then - IFS='' read -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 fi if [ "$user" ]; then - IFS='' read -s -p 'Desired password: ' password + IFS='' read -r -s -p 'Desired password: ' password echo fi @@ -117,7 +117,7 @@ if ./start; then echo "Let's test the daemon now." fi echo - echo '$' $rsync --list-only "$path" + echo '$' "$rsync" --list-only "$path" $rsync --list-only "$path" echo echo "You should see an empty folder; it's $moduledir." diff --git a/support/lsh.sh b/support/lsh.sh index db034228b..53727e9f0 100755 --- a/support/lsh.sh +++ b/support/lsh.sh @@ -13,7 +13,7 @@ do_cd=y # Default path is user's home dir (just like ssh) unless host is "lh". while : ; do case "$1" in -l) user="$2"; shift; shift ;; - -l*) user=`echo "$1" | sed 's/^-l//'`; shift ;; + -l*) user=$(echo "$1" | sed 's/^-l//'); shift ;; --no-cd) do_cd=n; shift ;; -*) shift ;; localhost) shift; break ;; @@ -25,7 +25,7 @@ done if [ "$user" ]; then prefix='' if [ $do_cd = y ]; then - home=`perl -e "print((getpwnam('$user'))[7])"` + home=$(perl -e "print((getpwnam('$user'))[7])") prefix="cd '$home' &&" fi sudo -H -u "$user" sh -c "$prefix $*" @@ -33,5 +33,6 @@ else if [ $do_cd = y ]; then cd || exit 1 fi + # shellcheck disable=2294 eval "${@}" fi diff --git a/support/rsync-no-vanished b/support/rsync-no-vanished index 892c90baa..f14351ac4 100755 --- a/support/rsync-no-vanished +++ b/support/rsync-no-vanished @@ -17,8 +17,8 @@ set -o pipefail # This filters stderr without merging it with stdout: { $REAL_RSYNC "${@}" 2>&1 1>&3 3>&- | grep -E -v "$IGNOREOUT"; ret=${PIPESTATUS[0]}; } 3>&1 1>&2 -if [[ $ret == $IGNOREEXIT ]]; then +if [[ $ret == "$IGNOREEXIT" ]]; then ret=0 fi -exit $ret +exit "$ret"