in reply to Exiting backticks early

You can try to filter by piping thru head on Unix, but I doubt this will kill the feeding process.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Exiting backticks early
by Eily (Monsignor) on Mar 07, 2018 at 19:31 UTC

    Well cat | head -n3 prints "cat: write error: No space left on device" on stderr and terminates when I type a fourth line so the writing process can be terminated (though I'm sure there are exceptions). Tested with cygwin on Windows BTW

Re^2: Exiting backticks early
by bobn (Chaplain) on Mar 09, 2018 at 19:09 UTC
    Isn't killing the feeding process done by SIGPIPE handling?
    $ perl -e ' @a = `cat /etc/passwd | head -3 `; print for @a' root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin $ ps auxww | fgrep 'cat /etc/passwd' bobn 26404 0.0 0.0 9376 764 pts/10 S+ 13:11 0:00 fgrep + --color=auto cat /etc/passwd $

    --Bob Niederman,

    All code given here is UNTESTED unless otherwise stated.