Solving real-world problems with Linux's proc filesystem
In the "redirect harder" section, the solution given to a program that needs an explicitly named file for standard input is:
In zsh the same thing can be accomplished with a more concise syntax:echo hello | python crap-prog.py /proc/self/fd/0
And, if your process wanted to seek the file (which isn't possible to do with a simple redirection of stdin), you could do:python crap-prog.py <(echo hello)
The main difference is that here, behind the scenes zsh creates and deletes a temporary file with the contents of the stdout of the program between the =().python crap-prog.py =(echo hello)Another neat thing you can do in zsh to solve the original problem is to create a global alias for stdin:
Then, whenever you typed "STDIN" on the command line, zsh would convert it to "/proc/self/fd/0". Then to make the exact equivalent of the original solution (but one that's easier to remember and type), you could simply write:alias -g STDIN=/proc/self/fd/0
A regular alias won't work here, since regular aliases only expand when they're the first part of a command. Global aliases will expand anywhere in the command line. So you just have to be a bit more careful with them.echo hello | python crap-prog.py STDIN---
The solution in the "phantom progress bar" section is cute, and a good demonstration of what's possible to do with /proc/$PID/fdinfo, but you could just use a ready made solution like either of these:
undefined