
はい、あなたが何を考えているのか知っています。 「一体誰がファイル名を指定するのでしょうか`a`b
?」
しかし、あなたが仮定しましょうする`a`b
(おそらくあなたではなく、クレイジーMacユーザーが作成したものかもしれません)というファイルがあり、あなたはrsync
それを望んでいます。確実な解決策:
rsync server:'./`a`b' ./.;
rsync 'server:./`a`b' ./.;
以下を提供します。
bash: line 1: a: command not found
rsync: [sender] link_stat "/home/tange/b" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1865) [Receiver=3.2.7]
rsync: [Receiver] write error: Broken pipe (32)
でも:
$ rsync 'server:./\`a\`b' ./.;
bash: line 3: a\: command not found
rsync: [sender] link_stat "/home/tange/\b" failed: No such file or directory (2)
:
rsync
私の注文は何ですか?しなければならない走る?
$ rsync --version
rsync version 3.2.7 protocol version 31
答え1
手動で二等分した後、rsyncのバグが発生して修正されました。commit 5c93dedf4538("SHELL_CHARSにバックティックを追加します。")、これはすぐにリリースされるrsync 3.2.8(まだリリースされていません)に表示されます。壊れたコミット6b8db0f6440b(「バックスラッシュエスケープを使用した引数保護イディオムの追加」)、3.2.4にあります。
緩和策として以前の引数解析動作()を使用するオプションがあります--old-args
。
rsync --old-args 'server:./\`a\`b' .
答え2
バージョンの問題です。サーバーのバージョンに依存せずにクライアントに依存しているようです。
v3.2.3とv3.2.7の間にはいくつかの問題がありました。
いいね:
$ rsync-v3.2.3 --rsync-path=rsync-v3.2.7 'server:./\`a\`b' ./.;
$ rsync-v3.2.3 --rsync-path=rsync-v3.2.3 'server:./\`a\`b' ./.;
$ rsync-v3.2.3 --rsync-path=rsync-v3.2.3 server:./"'"'`a`'"'"b ./.;
失敗する:
$ rsync-v3.2.7 --rsync-path=rsync-v3.2.7 'server:./\`a\`b' ./.;
bash: line 3: a\: command not found
rsync: [sender] link_stat "/home/tange/\b" failed: No such file or directory (2)
$ rsync-v3.2.7 --rsync-path=rsync-v3.2.3 'server:./\`a\`b' ./.;
bash: line 3: a\: command not found
rsync: [sender] link_stat "/home/tange/\b" failed: No such file or directory (2)
$ rsync-v3.2.3 --rsync-path=rsync-v3.2.3 'server:./`a`b' ./.;
bash: line 1: a: command not found
rsync: [sender] link_stat "/home/tange/b" failed: No such file or directory (2)
$ rsync-v3.2.3 --rsync-path=rsync-v3.2.7 'server:./`a`b' ./.;
bash: line 1: a: command not found
rsync: [sender] link_stat "/home/tange/b" failed: No such file or directory (2)
しかし、真剣に言えば、これは2回引用しなければならないほど災害が起こるのを待っているようです`
。
この点を指摘してくれた@dhagに感謝します。
残念ながら、バージョン3.2.7を使用して転送する方法については答えません。
答え3
rsync
3.0.0より前のバージョンをサポートする必要がない場合は、--secluded-args
aka -s
(以前の名前)を使用して、--protect-args
リモートユーザーのログインシェル(何でも可能)がファイル名を解釈する方法を心配する必要はありません。 rsh / sshによるrsyncing、正しく引用/エスケープを実行することはほとんど不可能です。マニュアル(3.2.7)から:
--secluded-args, -s This option sends all filenames and most options to the remote rsync via the protocol (not the remote shell command line) which avoids letting the remote shell modify them. Wildcards are ex‐ panded on the remote host by rsync instead of a shell. This is similar to the default backslash-escaping of args that was added in 3.2.4 (see --old-args) in that it prevents things like space splitting and unwanted special-character side-ef‐ fects. However, it has the drawbacks of being incompatible with older rsync versions (prior to 3.0.0) and of being refused by restricted shells that want to be able to inspect all the option values for safety. This option is useful for those times that you need the argu‐ ment's character set to be converted for the remote host, if the remote shell is incompatible with the default backslash-escpaing method, or there is some other reason that you want the majority of the options and arguments to bypass the command-line of the remote shell. If you combine this option with --iconv, the args related to the remote side will be translated from the local to the remote character-set. The translation happens before wild-cards are expanded. See also the --files-from option. You may also control this setting via the RSYNC_PROTECT_ARGS en‐ vironment variable. If it has a non-zero value, this setting will be enabled by default, otherwise it will be disabled by de‐ fault. Either state is overridden by a manually specified posi‐ tive or negative version of this option (note that --no-s and --no-secluded-args are the negative versions). This environment variable is also superseded by a non-zero RSYNC_OLD_ARGS export. This option conflicts with the --old-args option. This option used to be called --protect-args (before 3.2.6) and that older name can still be used (though specifying it as -s is always the easiest and most compatible choice).