Skip to content

Can't use read inside eval blocks #1844

Closed

Description

@zanchey

somefunc.fish:

function myecho
     read -l somevar
     echo $somevar
end

function somefunc
     eval myecho
end

read returns without setting any contents of the variable, probably because standard input is not as expected in eval.fish.

Activity

  1. added
    bug
    on Dec 4, 2014
  2. titosemi commented on Dec 4, 2014

    @titosemi

    Thanks @zanchey

  3. ridiculousfish commented on Mar 23, 2015

    @ridiculousfish
    Member

    The behavior here seems to have changed recently with b4aa2b7. I need to short this out.

  4. added this to the milestone on Mar 23, 2015
  5. ridiculousfish commented on Mar 23, 2015

    @ridiculousfish
    Member

    This was broken in fish 1.x as well, except with b4aa2b7 the prompt gets screwed up afterwards.

  6. ridiculousfish commented on Mar 24, 2015

    @ridiculousfish
    Member

    What's going on is that fish is not in the foreground process group for the tty (i.e. tcgetpgrp()). Instead, the keepalive process is. fish calls select() on the tty, waiting for input. When the input occurs (you press a key) it tries to read, but gets EIO since it's no in the foreground. With b4aa2b7 we (correctly, IMO) stop reading when a read from stdin errors, so we end up exiting out.

    One possible fix is to make builtin_read try to grab the tty via tcsetpgrp.

  7. modified the milestones: next-major, on Mar 24, 2015
  8. krader1961 commented on Mar 29, 2017

    @krader1961
    Contributor

    This is probably a dup of #1362 and several other issues. Nonetheless, I'm leaving this open so that others searching for issues that talk about a particular set of symptoms are more likely to find a match.

  9. mqudsi commented on Sep 19, 2018

    @mqudsi
    Contributor

    I believe this is fixed by d9f3414 and fa66ac8. The test cases now run fine under WSL or FreeBSD.

  10. modified the milestones: fish-future, fish-3.0 on Sep 19, 2018
  11. locked as resolved and limited conversation to collaborators on Apr 17, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions