Created attachment 9416 [details] Patch to add -o support https://github.com/MalloryA/busybox/commit/2b66ae249d87c3b1c427cc87862ad6612b27c271 -o opens /dev/tty and connects it to the stdin of the commands that get executed. Example: say we want to delete some files interactively. We cannot do that with xargs without the -o option because the `rm -i` command does not receive an interactive stdin. But if we add `-o`, then xargs will ensure that /dev/tty is connected as stdin and `rm -i` will show us a prompt and wait: ``` % touch a b c % echo a b c | xargs -o rm -i ``` The -o option is available in GNU and FreeBSD versions of xargs as non-POSIX extensions. Attached is a patch generated by `git format-patch`. I put the same patch on GitHub too: https://github.com/MalloryA/busybox/commit/2b66ae249d87c3b1c427cc87862ad6612b27c271
Buggy. You must not dup2 to stdin, you lose the original input. + if (dup2(*fd, STDIN_FILENO) != 0) + bb_error_msg_and_die("can't read from /dev/tty"); The error message is wrong. Anyway, use xdup2() which never returns failure. + if ((fd = xopen("/dev/tty", O_RDONLY)) == -1) + bb_error_msg_and_die("can't open /dev/tty"); xopen() never returns -1.
Fixed in git.