Reading from stdin from a command executed with xargs

Using xargsdid what I did not expect, although I think it makes sense. This is not what I did, but it is an example that should show what happened.

fn.sh

#!/usr/bin/bash
index=1
for arg in "$@"; do echo "Arg #$index = '$arg'"; let ++index; done
read -p "type something followed by enter: "  a
echo "You typed '$a'."

Now here is the command:

echo boo hoo | xargs ./fn.sh

Now I want to fn.shbe able to read from stdinto allow user interaction, but this was usurped xargs. I think I could get xargsto read from a temporary file, but I was wondering if it could use an unnamed file.

+4
source share
2 answers

I never used cygwin, but usually I would do something like this:

xargs -a <(echo boo hoo) ./fn.sh

-a xargs , <( ) ( cygwin) - , ( , , /dev/fd), , .

, , xargs, .

+7

, , man- xargs.

-o :

-o: stdin /dev/tty . , , xargs .

, .

0

All Articles