Y
Hacker News
new
|
ask
|
show
|
jobs
by
mr_mitm
822 days ago
How could curl detect where it's piped to?
2 comments
take-five
822 days ago
Something like (in Python)
os.isatty(sys.stdout.fileno())
link
Zambyte
822 days ago
That doesn't say where it's piped though. It could be redirected to a file, or piped to something harmless like jq.
link
timando
822 days ago
Iterate through /proc/<pid>/fd and check for the pipe id in the symlink target.
link
os.isatty(sys.stdout.fileno())