Skip to content

Character ^ fails command. #81

Closed
Closed

Description

@jeanlaurent

Not sure it's a bug, but quite anoying, If I type a ^ wihin the command line, the command fails.

Example :

jlm@4wOot ~/s/mycode> git reset --hard HEAD^
fish: Expected redirection specification, got token of type 'End of command'
git reset --hard HEAD^
                      ^
jlm@4wOot ~/s/mycode> 

The ^ is quite useful when using git in a terminal.

Activity

  1. ridiculousfish commented on Jun 8, 2012

    @ridiculousfish
    Member

    ^ is a redirection (like |) for I believe stderr. So this is behaving as designed.

    You can defeat it through quotes: git checkout "HEAD^"

    Leaving this bug open because it is annoying. Anyone please chime in if you have an idea for fixing this.

  2. soli commented on Jun 9, 2012

    @soli

    escaping ^ with a \ works fine (same as escaping {} as {} in a find command for instance).
    I don't really see this as a bug, but it might be wise to add these to the FAQ.

    Another option might be to get the parser to fallback on ^ when a redirection does not make sense (syntactically) but it might lead to tricky situations where depending on the rest of the line the user cannot easily guess if his ^ will be escaped or not.

    May be simply add to the error message the suggestion about escaping ^ ...

  3. mpe commented on Jun 13, 2012

    @mpe

    This kind of sucks, quoting or escaping is annoying because I never remember to do it.

    I know that the existing redirection characters are treated the same way in existing shells, but given that this is a new redirection character I think it should get some special handling to make this existing usage work.

  4. martinklepsch commented on Aug 3, 2012

    @martinklepsch

    #168 seems to be a dupe of this

  5. schwa commented on Apr 20, 2013

    @schwa

    Unfortunately this is a "back to bash" show stopper for me.

  6. ridiculousfish commented on Apr 20, 2013

    @ridiculousfish
    Member

    @schwa, you'll be glad to know that this particular case has been fixed as #168 . ^ is now only a redirection if it is the first character in a token, which is never used in git.

    git checkout HEAD^  <--- passes HEAD^ to git
    git log ^ /tmp/error.txt  <---- redirects stderr
    

    Closing this - I think the current behavior satisfies everyone.

  7. aeosynth commented on May 24, 2013

    @aeosynth
    Contributor

    git does use ^ as the first character in some places:

    https://www.kernel.org/pub/software/scm/git/docs/git-rev-list.html#_description

    Thus, the following command:

    $ git rev-list foo bar ^baz
    

    means "list all the commits which are reachable from foo or bar, but not from baz".

  8. dag commented on May 24, 2013

    @dag
    Contributor

    Not sure I like this fix, feels vaguely similar to the bash behavior for unmatched wildcards?

  9. danieljames commented on May 24, 2013

    @danieljames
    Contributor

    For what it's worth, subversion uses ^ as a short cut for the top of the repository, e.g.

    svn diff "^/trunk"
    

    Although I don't find it a burden to quote it.

  10. removed this from the fish-future milestone on Feb 8, 2016
  11. 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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions