-
-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the idiomatic way to read from the standard input? #1881
Comments
Some elvish functions support pipelines directly, but other's don't, and I also find this pretty confusing. But although the names are totally not intuitive to me, fn elvish-updates { |&n=10|
var sep = "\n----------------------------"
curl "https://api.github.com/repos/elves/elvish/commits?per_page="$n |
all (from-json) |
each {|issue| echo $sep; echo (styled $issue[sha][0..12]" "$issue[commit][committer][date] bold)":\n" (styled (re:replace "\n" " " $issue[commit][message]) yellow) }
}
This is the impenetrable first sentence description of
https://elv.sh/ref/builtin.html#all I personally don't really understand that sentence. If |
The very short answer to the question about
|
Anyway, on reading from a pipe: It's tricky if the pipe contains a mixture of bytes and values. In general, I think it's best to avoid that. To read all the bytes from a pipe, there is All this takes a bit of getting used to. I made quite an impressive number of mistakes when I was learning elvish, many of them silly in retrospect. |
I have recently started learning the language, and I am trying to figure out how I can write functions that work well in pipelines. Writing to pipes is fairly obvious (just use
echo
/write
for bytes andput
for values), however, reading from them is less so.The text was updated successfully, but these errors were encountered: