You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"&" interpreted as backgrounding symbol inside of words #3878
This is not a bug in the usual sense of the implementation not behaving as documented or producing an incorrect result. The behavior is consistent with the documented fish syntax and consistent with how bash and zsh behave.
Whether it should be changed to be friendlier to inexperienced users is open for debate. But you then open a can of worms. For example, should this semicolon be treated as a regular character rather than terminating the first echo foo statement: echo foo;echo bar. If the ampersand in echo foo&echo bar is no longer special because it isn't followed by whitespace then shouldn't we treat a semicolon in the same situation analogously? What about echo foo&;echo bar? There are similar examples but I think you get the idea.
This came up in #967, in relation to pasting. The issue is that "&" often appears in URLs, which are often used e.g. with curl or wget. So this happens much more often than with ";".
It caught me by surprise, because I've never actually used it this way (I've also never used semicolon this way, but then I've always used echo foo; echo bar, with a space after but not before).
Of course all of this would be moot if #1381 were implemented, and I'm working towards making pasting slightly more friendly.
While I would welcome enhancing bg so it can be used to directly launch an external command in the background (issue #1381) I doubt we'll ever get rid of & as syntax for doing so. At least not in the next few years. That is the sort of change that requires at least one, possibly two, major releases to remove.
I'm withdrawing my request. If something is to be changed here, I'd prefer #1381 - backgrounding is a prime example of something that should be a bit more explicit than an "&" at the end of the line (or in the middle of a word).
Activity
krader1961 commentedon Mar 2, 2017
This is not a bug in the usual sense of the implementation not behaving as documented or producing an incorrect result. The behavior is consistent with the documented fish syntax and consistent with how bash and zsh behave.
Whether it should be changed to be friendlier to inexperienced users is open for debate. But you then open a can of worms. For example, should this semicolon be treated as a regular character rather than terminating the first
echo foostatement:echo foo;echo bar. If the ampersand inecho foo&echo baris no longer special because it isn't followed by whitespace then shouldn't we treat a semicolon in the same situation analogously? What aboutecho foo&;echo bar? There are similar examples but I think you get the idea.faho commentedon Mar 2, 2017
Some context might be nice:
This came up in #967, in relation to pasting. The issue is that "&" often appears in URLs, which are often used e.g. with
curlorwget. So this happens much more often than with ";".It caught me by surprise, because I've never actually used it this way (I've also never used semicolon this way, but then I've always used
echo foo; echo bar, with a space after but not before).Of course all of this would be moot if #1381 were implemented, and I'm working towards making pasting slightly more friendly.
krader1961 commentedon Mar 4, 2017
While I would welcome enhancing
bgso it can be used to directly launch an external command in the background (issue #1381) I doubt we'll ever get rid of&as syntax for doing so. At least not in the next few years. That is the sort of change that requires at least one, possibly two, major releases to remove.faho commentedon Mar 16, 2017
I'm withdrawing my request. If something is to be changed here, I'd prefer #1381 - backgrounding is a prime example of something that should be a bit more explicit than an "&" at the end of the line (or in the middle of a word).