I set up a pipe returning the name of a package I'd like to install using apt-get
:
... | xargs -I _ sudo apt install _
However, apt-get
can't read from stdin in this case and exits with:
Do you want to continue? [Y/n] Abort.
I know about the -y
flag to install the package without user confirmation, but I'd like to actually see the confirmation.
Is there a way to forward the package name to apt-get
while still allowing it to read from stdin?
Putting apt-get
on the left side of the whole command is not an option since I don't want apt-get
to be executed if an ealier command in the pipe is aborted, using the set -o pipefail
option.
echo "Please enter something." | xargs -I _ echo _; read
, I see the output and it requests the read. I don't see how apt would do something else? Or am I assuming something wrong?read
outside the pipe. In the question,apt
runs inside the pipe. Try something likeecho foo | xargs sh -c "read x; echo $x"
apt-get
stage to a variable and then executeapt-get
on the value of the variable if it is set. Am I correctly assuming that the variable won't be set if the pipe fails?