TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Pipexec – Handling pipe of commands like a single command

146 pointsby JNRoweabout 1 year ago

14 comments

qazxcvbnmabout 1 year ago
It seems to me that this can be achieved by the following bash-native way of creating extra file descriptor pipes:<p><pre><code> pipe_path=&quot;$(mktemp -u)&quot; mkfifo &quot;$pipe_path&quot; exec 3&lt;&gt;&quot;$pipe_path&quot; rm -f &quot;$pipe_path&quot; </code></pre> Here, exec associates the file descriptor (3 here, replace with any desired descriptor) with the pipe created by mkfifo. The filesystem path to the pipe is removed immediately after we obtain a file descriptor to it, so that the the only remaining reference to the pipe in the system would be from this script, and thus when the script dies, the kernel will automatically free the pipe.<p>An example use case would be like so: <a href="https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;a&#x2F;216475&#x2F;585293" rel="nofollow">https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;a&#x2F;216475&#x2F;585293</a>
评论 #39657564 未加载
chubotabout 1 year ago
Hm interesting, also see dgsh, the directed graph shell<p><a href="https:&#x2F;&#x2F;www2.dmst.aueb.gr&#x2F;dds&#x2F;sw&#x2F;dgsh&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www2.dmst.aueb.gr&#x2F;dds&#x2F;sw&#x2F;dgsh&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;dspinellis&#x2F;dgsh">https:&#x2F;&#x2F;github.com&#x2F;dspinellis&#x2F;dgsh</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21700014">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21700014</a><p>dgsh uses Unix domain sockets, not pipes. I don&#x27;t remember exactly why, but it&#x27;s in the paper, perhaps to avoid deadlocks compared to pipes.<p>I&#x27;d also be interested in some more examples with pipexec or dgsh!
评论 #39657201 未加载
koolbaabout 1 year ago
This is neat, but outside of a contrived ouroboros example, what’s a real world use case for this?<p>There’s a natural flow of outputs becoming inputs and I’m struggling to identify a situation where I would feed things back into the source. Also, named pipes kind of solve that already.
评论 #39656667 未加载
评论 #39657087 未加载
评论 #39657537 未加载
评论 #39657042 未加载
评论 #39657780 未加载
评论 #39656982 未加载
gorgoilerabout 1 year ago
What a beautifully designed tool. In our Python codebase we end up reaching for inline sh scripting a lot whenever we need to pipe between processes. In a way it feels ok — after all, no one has any qualms about reaching for inline SQL to get things done, so what’s wrong with a little shell script in the middle of a Python module?<p>Just as there are efforts — both wise and misguided — to represent the building of an SQL query with Python syntax, what Python tools are there to build sh pipelines between processes with a more pythonic syntax? Do they provide value in excess of the novelty tax one has to pay for using a non standard library?
评论 #39658608 未加载
diekhansabout 1 year ago
It&#x27;s an interesting package, and I have some of the use cases it appears to address. However, the documentation is inadequate to quickly understand how to robustly build some of the more complex cases. In particular, how to build bash-style process substitution. Robust here is the pipeline exits non-zero if any of the substituted processes fail, as demonstrated by this example:<p><pre><code> #!&#x2F;bin&#x2F;bash set -beEu -o pipefail cat &lt;(date) &lt;(false) echo did not exit non-zero </code></pre> If this is addressed, it would be worth more time to figure out Pipexec.
agumonkeyabout 1 year ago
Considering how airflow&#x2F;dagster are trendy these days, concurrency too.. I assume a leaner, os&#x2F;language agnostic solution for this problem might emerge not too far in the future.
wwalexanderabout 1 year ago
In the category of “command line representations of graphs” see also ffmpeg’s filtergraphs [1].<p>[1] <a href="https:&#x2F;&#x2F;ffmpeg.org&#x2F;ffmpeg-filters.html#Filtering-Introduction" rel="nofollow">https:&#x2F;&#x2F;ffmpeg.org&#x2F;ffmpeg-filters.html#Filtering-Introductio...</a>
评论 #39657491 未加载
pipeline_peakabout 1 year ago
Isn’t this exactly what shell scripting is for?
mmgutzabout 1 year ago
Wasn&#x27;t understanding the graphics in the README until I used light mode.
k3vinwabout 1 year ago
It would be cool to have a tool similar to this, but for composing a graph of commands similar to aws step functions (or Jenkins pipelines). I’d call it mapexec :)
DebtDeflationabout 1 year ago
Read the first word of the title and assumed this would be about some new bot&#x2F;method for automating layoffs.
soygemabout 1 year ago
42 pipex, we meet again
snthpyabout 1 year ago
This is great, thanks!
keithalewisabout 1 year ago
&gt; Nobody will tell you:<p>&gt; stdin, stdout and stderr are artificial definitions.<p>Unless you RTFM.
评论 #39662066 未加载