Question

In the manual for zsh, in the section on Jobs & Signals, it says:

If a job is started with &| or &!, then that job is immediately disowned.

Is there some difference between the two ways of immediately disowning a job? If not, then why are there two different but very similar ways of doing it?

Was it helpful?

Solution

Is there a difference?

Interesting question. I cloned the git repo, started looking where it was added and I've found out that the commit which added the info to manual was the Initial commit. This may have mean that the change from CVS wasn't done with preserving commits, but I haven't looked any further when I saw the commit is from 2009.

I then had a look at the code and there lies the answer. In the list of tokens there is

...
"&|",       /* AMPERBANG      30 */
...

When parser approaches ampersand and sees either '!' or '|' after it, it automatically returns AMPERBANG as the token read. From this point there is no difference between those two.

I guess my answer for you is that There is no difference between those two in current versions of ZSH.

Why are there two different tokens having the same meaning?

From the code, it looks like it is a keyboard-related thing. There are many places in the code where these two are used for the same meaning (literally if (d == '!' || d == '|') appears many times there. The only keyboard-related reason I've found is that, apparently, on Swiss keyboard, you can type | by using AltGr+1 Where in US (and similar) layouts exclamation mark is produced by Shift+1. I've found other reasons, but highly improbable due to the narrow audience of their users.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top