TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Higher-order Shell

58 点作者 r11t超过 15 年前

4 条评论

nixme超过 15 年前
Zsh already has the first program built-in using the = expansion. For his example it would be:<p><pre><code> xdvi =(curl http://www.diku.dk/~andrzej/papers/RC.dvi) </code></pre> Yet another reason why you should switch to zsh <i>today</i> :)<p>More about expansions in zsh: <a href="http://zsh.sourceforge.net/Doc/Release/zsh_13.html" rel="nofollow">http://zsh.sourceforge.net/Doc/Release/zsh_13.html</a>
评论 #1058439 未加载
tel超过 15 年前
I like the attempt to use Haskell type signatures as terse documentation. For 'tmp' it pretty nearly tells the whole story (especially rewritten flipping the first two arguments as below)<p><pre><code> tmp :: (FilePath -&#62; IO ()) -&#62; (Stream -&#62; IO ()) Transforms file-accepting function to work on an input stream. </code></pre> 'keep' is a bit more ambiguous, but I think it's more clear if you write it instead as<p><pre><code> keep :: IO a -&#62; IO [()] </code></pre> which has parallels to 'repeat :: a -&#62; [a]' and suggests that the first action will be "kept" and repeated periodically, throwing away the output. At this point, you have to guess when it repeats, but since you provide 'keep' no further information, blocking until files update is a pretty logical guess.
评论 #1057912 未加载
there超过 15 年前
while not helpful for his examples, some programs that don't grok "-" as a shortcut to read data from stdin (or a pipe) are ok being passed "/dev/stdin" as the filename.
评论 #1058441 未加载
gnosis超过 15 年前
<i>"Surely I was not the first to write the following two higher-order programs..."</i><p>He's right. There is, for example, <i>rc</i> (the Plan 9 shell, made in 1989).<p>The following is from section 10, "Pipeline branching" of: <a href="http://plan9.bell-labs.com/sys/doc/rc.html" rel="nofollow">http://plan9.bell-labs.com/sys/doc/rc.html</a><p><i>"&#60; or &#62; followed by a command in braces causes the command to be run with its standard output or input attached to a pipe. The parent command (cmp in the example) is started with the other end of the pipe attached to some file descriptor or other, and with an argument that will connect to the pipe when opened (e.g., /dev/fd/6)."</i>
评论 #1058026 未加载