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

There should be a $platform:tty-name variable #1594

Closed
krader1961 opened this issue Aug 5, 2022 · 3 comments
Closed

There should be a $platform:tty-name variable #1594

krader1961 opened this issue Aug 5, 2022 · 3 comments

Comments

@krader1961
Copy link
Contributor

While working on issue #1263 it occurred to me it would be good if users didn't have to do something like this to write portable code:

use platform
var tty-name
if $platform:is-unix {
    set tty-name = "/dev/tty"
} else if $platform:is-windows {
    set tty-name = "con:"
} else {
    fail "could not determine the tty device name"
}

I thought Go had a constant that defined the appropriate string for each supported platform but I can't find it. Regardless, this seems like something Elvish should provide via a $platform:tty-name variable.

@krader1961
Copy link
Contributor Author

I looked at the Go source code and could not find a single mention of CON:. There are a handle of uses of /dev/tty but no constant that is exposed by the Go stdlib. That surprises me but I still believe adding a platform:tty-name variable will make it easier for a user to write portable Elvish code.

@iandol
Copy link
Contributor

iandol commented Jan 4, 2023

This should be fixed by 34dab39 ?

@krader1961
Copy link
Contributor Author

@iandol, Good catch. I had forgotten I had opened this issue when I opened #1633. Closing this as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants