Skip to content

Commit 82cddee

Browse files
committed
Add ghe-rsync wrapper command, silence vanished file warnings
1 parent caa2b2b commit 82cddee

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

libexec/ghe-rsync

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
#/ Usage: ghe-rsync
3+
#/ Run rsync with silenced vanished file warnings (non-critical).
4+
#
5+
# Based on the rsync-no-vanished support script included with rsync:
6+
# https://bugzilla.samba.org/show_bug.cgi?id=10356
7+
8+
set -o pipefail
9+
10+
# Filter vanished file warnings from stderr. The complex redirections are
11+
# necessary to filter stderr while also keeping stdout and stderr separated.
12+
IGNOREOUT='^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
13+
(rsync "${@}" 3>&1 1>&2 2>&3 3>&- |
14+
(egrep -v "$IGNOREOUT" || true)) 3>&1 1>&2 2>&3 3>&-
15+
res=$?
16+
17+
# rsync exits with 24 when vanished files are detected.
18+
if [ $res = 24 ]; then
19+
res=0
20+
fi
21+
22+
exit $res

0 commit comments

Comments
 (0)