backslash preceding characters
来源:互联网 发布:现在java主流框架 编辑:程序博客网 时间:2024/06/03 13:50
In regular, unquoted situations, every character with a backslash preceding it has it's backslash processed, whether it needs it or not.
But inside quotes or a heredoc, only the few listed characters are treated specially. Backslashes preceding all other regular characters will remain literal.
command + # output + # explanation:
A heredoc does not process quotemarks, but it does process "$" and "`", so substitutions still happen. It also processes backslashes if they are in front of the reserved characters, allowing you to escape them if needed. All other characters are ignored just as in the quoted situation above.
Note that if the delimiting word (the opening EOF) is quoted or backslashed, it won't process anything. The entire text will become literal.
As for this:
The way `..` processes backslashes appears to be rather confusing overall. Seehere. It appears to be doing some kind of double-expansion, in fact.
$(..), on the other hand, simply processes everything it contains as a regular command subshell. Just another reason not to use backticks!
But inside quotes or a heredoc, only the few listed characters are treated specially. Backslashes preceding all other regular characters will remain literal.
command + # output + # explanation:
Code:
echo \z # z #backslash interpreted.echo \\z # \z #2 backlashes become one.echo "\z" # \z #backslash not intepreted, not preceding a special characterecho "\\z" # \z #2 backslashes become one. "\" precedes a special character, another '\'.
Code:
foo=barcat <<EOF\z\\z"\z""\\z"echo $fooecho \$foo$( echo $foo )$( echo \$foo )EOF#output:\z\z"\z""\z"echo barecho $foobar$foo
As for this:
Code:
$ var=test$ echo `echo \$var`test
$(..), on the other hand, simply processes everything it contains as a regular command subshell. Just another reason not to use backticks!
0 0
- backslash preceding characters
- string format preceding zeros
- preceding-sibling::*[1]
- characters
- xsl的preceding::跟following::
- preceding轴和following轴
- preceding轴的使用实例
- warning: backslash and newline separated by space
- backslash-newline at end of file
- warning: backslash and newline separated by space
- OLAP 函数 (rows 2 preceding / unbounded preceding) ORACLE OLAP 函数
- Removing the trailing file name and backslash from a path
- Why can be so about Regex.IsMatch with double backslash?
- 斜杠(Slash)与反斜杠(backslash)
- (报错)backslash-newline at end of file
- Personal Characters
- ASCII Characters
- Special characters
- 内脏作息时间表
- 【贪心】+【map】
- 快速排序
- MFC中ShellManager的使用
- 求数n和n!的因子和
- backslash preceding characters
- C for ios --- 选择结构Switch
- c++作业3
- Java自定义注解和运行时靠反射获取注解
- javatest
- Spring boot项目搭建案例
- embox2d-helpers.js
- 架构设计:系统存储(28)——分布式文件系统Ceph(挂载)
- C关键字const