Lightfire228@pawb.socialtolinuxmemes@lemmy.world•My heart goes out to shell programmers who have to support posix sh
1·
22 hours agonushell is pretty good. I use it for my main shell
although, i still prefer writing utilities in python over nu scripts
that is a little more complicated
p.communicate()
will take a string (or bytes) and send it to the stdin of the process, then wait forp
to finish executionthere are ways to stream input into a running process (without waiting for the process to finish), but I don’t remember how off the top of my head
from shutil import which from subprocess import Popen, PIPE, run from pathlib import Path LS = which('ls') REV = which('rev') ls = run([LS, Path.home()], stdout=PIPE) p = Popen([REV], stdin=PIPE, stdout=PIPE) stdout, stderr = p.communicate(ls.stdout) print(stdout.decode('utf-8'))