Skip to content

Parse errors for -c commands don't cause fish to return error #9888

Closed

Description

@faho

Also happens with 3.6.1:

> fish -c 'begin'
fish: Missing end to balance this begin
begin
^~~~^
> echo $status
0
> echo begin | fish
fish: Missing end to balance this begin
begin
^~~~^
> echo $status
127

This should probably cause us to return an error code as well, and abort execution - in case there's multiple -c.

I'm not sure why we return 127 if it's piped, which is typically "command not found", but that's a separate thing.

Activity

  1. added
    bugSomething that's not working as intended
    on Jul 12, 2023
  2. added this to the fish 3.6.2 milestone on Jul 12, 2023
  3. faho commented on Jul 12, 2023

    @faho
    MemberAuthor

    Alright I did the simple, targeted fix. In particular we allow multiple -c commands, and we will continue on even if one failed - this is explicitly tested.

    So this returns a failing status if the last -c command had a parser error, which is the typical case.

    I don't love this - we typically stop for syntax errors early - we don't execute a file if it has a syntax error, and it feels weird to be so lax here.

    I also don't love the 127 status, which was added in 6044ac7 as far as I can tell. But since that's the status we get here, that's what we'll return for consistency (note that the int return from run_command_list is, as far as I can tell, a lie - it's effectively a bool).

  4. added a commit that references this issue on Oct 1, 2023
    72edd88
  5. added a commit that references this issue on Feb 6, 2024
    a6c36a0
  6. locked as resolved and limited conversation to collaborators on Apr 20, 2026
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

    bugSomething that's not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions