为什么有时空白需要各地的元字符?
几个月前,我刻在了我的手臂 fork炸弹和我跳过了空格,因为我觉得它看起来没有他们更好。但让我失望的是,有时(不总是),当我在一个shell中运行它,它不会启动一个叉炸弹,但它只是给出了一个语法错误。
A few months ago I tattooed a fork bomb on my arm, and I skipped the whitespaces, because I think it looks nicer without them. But to my dismay, sometimes (not always) when I run it in a shell it doesn't start a fork bomb, but it just gives a syntax error.
bash: syntax error near unexpected token `{:'
昨天它发生了,当我试图在一个朋友的击 shell中运行它,然后我说空白,它突然的工作,:(){:|:&放大器; };
而不是:(){:|:&放大器;};
Yesterday it happened when I tried to run it in a friend's Bash shell, and then I added the whitespace and it suddenly worked, :(){ :|:& };:
instead of :(){:|:&};:
请问空白事项;我有我的胳膊上纹一个语法错误?!
Does the whitespace matter; have I tattooed a syntax error on my arm?!
它似乎总是在工作 zsh的,但不是在Bash的。
It seems to always work in zsh, but not in Bash.
一个相关的问题没有解释有关空格什么,这确实是我的问题; 为什么空白需要猛砸要能正确解析呢?
A related question does not explain anything about the whitespaces, which really is my question; Why is the whitespace needed for Bash to be able to parse it correctly?
题外话更新:我说,有插图中的每一个字符,这又使得code解析的一个空白修补纹身
Off-topic update: I patched the tattoo by saying that there is a whitespace inbetween every character, which makes the code parsable again.
: ( ) { : | : & } ; :
有是字符分隔标记在BASH的列表。这些字符被称为的元字符的,他们是 |
,&安培;
,;
,(
,)
,<
,>
,空格和标签即可。在另一方面,大括号( {
和}
)只是普通的字符构成的话。
There is a list of characters that separate tokens in BASH. These characters are called metacharacters and they are |
, &
, ;
, (
, )
, <
, >
, space and tab. On the other hand, curly braces ({
and }
) are just ordinary characters that make up words.
在省略第二空间}
会做,因为&安培;
是一个元字符。因此,你的纹身应该至少有一个空格字符。
Omitting the second space before }
will do, since &
is a metacharacter. Therefore, your tattoo should have at least one space character.
:(){ :|:&};: