Skip to content

Commit

Permalink
A repeated --old-args does more escape disabling.
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneD committed Jan 10, 2022
1 parent 6b8db0f commit 635d8c0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
15 changes: 11 additions & 4 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ enum {OPT_SERVER = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG, OPT_BLOCK_SIZE,
OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_BWLIMIT, OPT_STDERR,
OPT_OLD_COMPRESS, OPT_NEW_COMPRESS, OPT_NO_COMPRESS,
OPT_OLD_COMPRESS, OPT_NEW_COMPRESS, OPT_NO_COMPRESS, OPT_OLD_ARGS,
OPT_STOP_AFTER, OPT_STOP_AT,
OPT_REFUSED_BASE = 9000};

Expand Down Expand Up @@ -781,7 +781,7 @@ static struct poptOption long_options[] = {
{"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
{"from0", '0', POPT_ARG_VAL, &eol_nulls, 1, 0, 0},
{"no-from0", 0, POPT_ARG_VAL, &eol_nulls, 0, 0, 0},
{"old-args", 0, POPT_ARG_VAL, &old_style_args, 1, 0, 0},
{"old-args", 0, POPT_ARG_NONE, 0, OPT_OLD_ARGS, 0, 0},
{"no-old-args", 0, POPT_ARG_VAL, &old_style_args, 0, 0, 0},
{"protect-args", 's', POPT_ARG_VAL, &protect_args, 1, 0, 0},
{"no-protect-args", 0, POPT_ARG_VAL, &protect_args, 0, 0, 0},
Expand Down Expand Up @@ -1608,6 +1608,13 @@ int parse_arguments(int *argc_p, const char ***argv_p)
compress_choice = NULL;
break;

case OPT_OLD_ARGS:
if (old_style_args <= 0)
old_style_args = 1;
else
old_style_args++;
break;

case 'M':
arg = poptGetOptArg(pc);
if (*arg != '-') {
Expand Down Expand Up @@ -1927,7 +1934,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)

if (old_style_args < 0) {
if (!am_server && (arg = getenv("RSYNC_OLD_ARGS")) != NULL && *arg)
old_style_args = atoi(arg) ? 1 : 0;
old_style_args = atoi(arg);
else
old_style_args = 0;
}
Expand Down Expand Up @@ -2477,7 +2484,7 @@ char *safe_arg(const char *opt, const char *arg)
int len2 = strlen(arg);
int extras = escape_leading_dash ? 2 : 0;
char *ret;
if (!protect_args && (!old_style_args || (!is_filename_arg && opt != SPLIT_ARG_WHEN_OLD))) {
if (!protect_args && old_style_args < 2 && (!old_style_args || (!is_filename_arg && opt != SPLIT_ARG_WHEN_OLD))) {
const char *f;
for (f = arg; *f; f++) {
if (strchr(escapes, *f))
Expand Down
23 changes: 13 additions & 10 deletions rsync.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2187,14 +2187,16 @@ your home directory (remove the '=' for that).
even wildcards escaped). The only active wildcard characters on the remote
side are: `*`, `?`, `[`, & `]`.

If you have a script that wants to use old-style arg splitting, this option
should get it going.
If you have a script that wants to use old-style arg splitting in the
filenames, specify this option once. If the remote shell has a problem
with any backslash escapes, specify the option twice.

You may also control this setting via the RSYNC_OLD_ARGS environment
variable. If this variable has a non-zero value, this setting will be
enabled by default, otherwise it will be disabled by default. Either state
is overridden by a manually specified positive or negative version of this
option (the negative is `--no-old-args`).
variable. If it has the value "1", rsync will default to a single-option
setting. If it has the value "2" (or more), rsync will default to a
repeated-option setting. If it is "0", you'll get the default escaping
behavior. The environment is always overridden by manually specified
positive or negative options (the negative is `--no-old-args`).

0. `--protect-args`, `-s`

Expand All @@ -2212,7 +2214,7 @@ your home directory (remove the '=' for that).
`--files-from` option.

You may also control this setting via the RSYNC_PROTECT_ARGS environment
variable. If this variable has a non-zero value, this setting will be
variable. If it has a non-zero value, this setting will be
enabled by default, otherwise it will be disabled by default. Either state
is overridden by a manually specified positive or negative version of this
option (note that `--no-s` and `--no-protect-args` are the negative
Expand Down Expand Up @@ -4162,9 +4164,10 @@ file is included or excluded.
0. `RSYNC_OLD_ARGS`
Specify a non-zero numeric value if you want the `--old-args` option to be
enabled by default, or a zero value to make sure that it is disabled by
default. (First supported in 3.2.4.)
Specify a "1" if you want the `--old-args` option to be enabled by default,
a "2" (or more) if you want it to be enabled in the option-repeated state,
or a "0" to make sure that it is disabled by default. (First supported in
3.2.4.)
0. `RSYNC_PROTECT_ARGS`
Expand Down

0 comments on commit 635d8c0

Please sign in to comment.