diff options
author | Wayne Davison <wayne@opencoder.net> | 2022-01-09 18:20:20 -0800 |
---|---|---|
committer | Wayne Davison <wayne@opencoder.net> | 2022-01-09 18:20:23 -0800 |
commit | 635d8c0632fa9549441ed468ff2cc167800f7fab (patch) | |
tree | 79bd61677e5dc78f9f80c3782c3beab1c2b105fb | |
parent | 6b8db0f6440b28d26ef807d17517715c47e62bd9 (diff) | |
download | rsync-635d8c0632fa9549441ed468ff2cc167800f7fab.tar.gz |
A repeated `--old-args` does more escape disabling.
-rw-r--r-- | options.c | 15 | ||||
-rw-r--r-- | rsync.1.md | 23 |
2 files changed, 24 insertions, 14 deletions
@@ -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}; @@ -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}, @@ -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 != '-') { @@ -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; } @@ -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)) @@ -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` @@ -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 @@ -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` |