malxau/yori

yenv: accept variable from stdin

t214c opened this issue · 4 comments

t214c commented

Hi, Malcolm.

I looked a lot and I couldn't find a tool that accepts standard input and saves it to a variable. Something like this:

echo string | yenv var
with the result:
echo %var% > string

This is very useful because currently you have to make a full for loop to do this.

What do you think?

malxau commented

I think I'm not understanding correctly :)

Isn't this
set var=$(echo string) ?

That's really capturing stdout of echo into the variable.

Readline.exe exists to read from the console and write to standard output, although note it's a direct console read, not a standard input read. A standard input read seemed redundant here, since it would just be reading from input and writing to output, like type. But if you wanted to set a variable to a user supplied value, it could be:

set var=$(readline)

t214c commented

set var=$(echo string)

Yeah, but this works only with Yori. I was talking about a tool that could work from any batch file.

It doesn't have to be yenv, it could be a new tool yset :)