Update github links.
[rsync.git] / support / rsync-slash-strip
blobb57e61c53b863b7adfdfc38decdaec6eee92da6e
1 #!/usr/bin/env bash
2 # This script can be used as an rsync command-line filter that strips a single
3 # trailing slash from each arg. That treats "src/" the same as "src", thus
4 # you need to use "src/." or "src//" for just the contents of the "src" dir.
5 # (Note that command-line dir-excludes would need to use "excl//" too.)
7 # To use this, name it something like "rs", put it somewhere in your path, and
8 # then use "rs" in place of "rsync" when you are typing your copy commands.
10 REAL_RSYNC=/usr/bin/rsync
12 args=()
13 for arg in "${@}"; do
14 if [[ "$arg" == --server ]]; then
15 exec $REAL_RSYNC "${@}"
16 exit $? # Not reached
18 if [[ "$arg" == / ]]; then
19 args=("${args[@]}" /)
20 else
21 args=("${args[@]}" "${arg%/}")
23 done
24 exec $REAL_RSYNC "${args[@]}"