Skip to content
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

yenv: accept variable from stdin #114

Open
t214c opened this issue Jul 2, 2023 · 4 comments
Open

yenv: accept variable from stdin #114

t214c opened this issue Jul 2, 2023 · 4 comments
Labels
fixed in master Changes have been made but are not in a stable release

Comments

@t214c
Copy link

t214c commented Jul 2, 2023

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
Copy link
Owner

malxau commented Jul 2, 2023

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
Copy link
Author

t214c commented Jul 2, 2023

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 :)

@malxau
Copy link
Owner

malxau commented Aug 19, 2023

Okay, I think I understand. I pushed a4a01f0 for this, although am still not happy; I think it should also support both a variable and value from stdin, but having done that, it could have a list of variables and values, and...

@malxau malxau added the fixed in master Changes have been made but are not in a stable release label Aug 19, 2023
@t214c
Copy link
Author

t214c commented Aug 24, 2023

Thanks a lot!

although am still not happy

Like I said, it doesn't have to be yenv at all. I just wanted a simple tool to abstract away the for loop (and character escaping) required to set a command output to a variable by piping. Advanced or multiple variable support is cherry on the top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in master Changes have been made but are not in a stable release
Projects
None yet
Development

No branches or pull requests

2 participants