Y
Hacker News
new
|
ask
|
show
|
jobs
by
mr_mitm
775 days ago
How could curl detect where it's piped to?
2 comments
take-five
775 days ago
Something like (in Python)
os.isatty(sys.stdout.fileno())
link
Zambyte
775 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
775 days ago
Iterate through /proc/<pid>/fd and check for the pipe id in the symlink target.
link
os.isatty(sys.stdout.fileno())