Skip to content

"&" interpreted as backgrounding symbol inside of words #3878

Closed

Description

@faho

It seems like fish interprets "&" as the special "background this" character even if it appears in the middle of a word:

> echo foo&echo bar
foo
bar
'echo foo&' has quit

which just seems awful.

Note that removing this behavior would be a compatibility break.

Activity

  1. added
    bug
    on Mar 2, 2017
  2. krader1961 commented on Mar 2, 2017

    @krader1961
    Contributor

    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.

  3. faho commented on Mar 2, 2017

    @faho
    MemberAuthor

    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 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.

  4. krader1961 commented on Mar 4, 2017

    @krader1961
    Contributor

    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.

  5. faho commented on Mar 16, 2017

    @faho
    MemberAuthor

    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).

  6. locked as resolved and limited conversation to collaborators on Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions