-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
bugSomething that's not working as intendedSomething that's not working as intended
Milestone
Description
I initially reported this issue here.
Description
When I pipe bash -i into a function (in this case, grep), the process gets stopped. @faho did some investigating and said:
The problem with bash -i seems to be that it grabs the terminal for itself - strace -e ioctl shows it doing one with TIOCSPGRP - which is the underlying syscall for tcsetpgrp on linux.
-- #1362 (comment)
My environment
$ fish --version
fish, version 2.7.1
$ echo $version
2.7.1
$ uname -a
Darwin Joshs-MacBook-Air-2.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64
$ echo $TERM
xterm-256colorDemo / how to reproduce
# ===== Setup =====
# get a clean environment
$ sh -c 'env HOME=$(mktemp -d) fish'
Welcome to fish, the friendly interactive shell
# shorten the prompt
josh@Joshs-MacBook-Air-2 /U/josh> function fish_prompt; echo '> '; end
# ===== Demo the issue =====
# hangs (I'll press C-c)
> bash -i -c 'echo hello >&2' | grep whatever
Job 1, 'bash -i -c 'echo hello >&2' | g…' has stopped
# its state is "stopped"
> jobs
Job Group State Command
1 24863 stopped bash -i -c 'echo hello >&2' | grep whatever
# when I foreground it, it completes as expected
> fg
Send job 1, 'bash -i -c 'echo hello >&2' | grep whatever' to foreground
hello
# ===== Slight variations that don't exhibit the issue =====
# use the grep command instead of the function
> bash -i -c 'echo hello >&2' | command grep whatever
hello
# run bash without the -i flag
> bash -c 'echo hello >&2' | grep whatever
hello
# ===== Other potentially useful info =====
# the grep function
> type grep
grep is a function with definition
function grep
command grep --color=auto $argv
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething that's not working as intendedSomething that's not working as intended