反引号内的反斜杠(\)以非显而易见的方式处理:
Run Code Online (Sandbox Code Playgroud)$ echo "`echo \\a`" "$(echo \\a)" a \a $ echo "`echo \\\\a`" "$(echo \\\\a)" \a \\a
但是,FAQ并未分解导致这种差异的解析规则。man bash我发现的唯一相关报价是:
当使用旧式的反引号形式的替换时,反斜杠保留其字面意思,除非后面是$,`或。
The "$(echo \\a)" and "$(echo \\\\a)" cases are easy enough: Backslash, the escape character, is escaping itself into a literal backlash. Thus every instance of \\ becomes \ in the output. But I'm struggling to understand the analogous logic for the backtick cases. What is the underlying rule and how does the observed output follow …