coreutils
coreutils copied to clipboard
Initial implementation of `stty`
I got annoyed that there was no stty yet, so I started working on it :)
In this initial version:
- ~Only binary flags are implemented (i.e. attributes that are enabled and disabled). This means that attributes like
tabNwhereNis a number between0and3is missing.~ This is now supported. --allis implemented.-F/--fileand-g/--saveare ignored.- Special characters, special settings and combined settings are missing.
- The
nixcrate is used (notlibc). Sadly, here are already some attributes that seem to be missing innix.
The tests are broken on my machine with the error:
thread 'main' panicked at 'Could not get terminal attributes: ENOTTY', src/uu/stty/src/stty.rs:83:44
So the stdout in cargo test does not seem to be a tty with terminal attributes. This might mean that we can't test stty at all? I'd like to try to find a workaround though.
wahou, amazing :)
@tertsdiepraam can we use crossterm for this (or are we using it ?)
Maybe we will have to use shell scripts for that TTY issue.
https://docs.rs/crossterm/latest/crossterm/index.html
Wahou indeed (pardon my french interjections ;)
I'm not currently using crossterm, but nix, which has support for most of the flags that we need for this. crossterm seems to be more about writing to the terminal than changing it's characteristics. The terminal size could come in handy but crossterm doesn't seem to support setting the size. So I'm afraid it will have to stay as low level as it is.
@tertsdiepraam I thought so as well, but maybe it could be an inspiration for which calls we should use.
I've ignored the tests that need to be run from a tty for now, but added some for the argument parsing. I've also added the special settings for the terminal (baudrate, columns, rows and line), but they can only be printed for now (not changed). With those changes this is at least ready to be considered somewhat of a viable first version, though of course there is much to be done :)
Apparently it needs some work on mac. It will take me a while to fix it though. If someone else wants to fix it up for mac, feel free to do so in the meantime.
@tertsdiepraam I belive mac os has no support for the cline field in termios.
Hence, should we ignore it ?
I believe the same problem is the cause for the other errors
Yeah I think that makes sense. The other issue with mac is that the baudrate is represented with a u32 instead of the baudrate enum.
Okay, so I think it's correct now. I can't test with mac, but I get the correct speed on FreeBSD. There are of course some minor issues and missing functionality with this implementation, but I think we can merge this and I can start opening issues for those.
sounds good, let's wait for the CI :) I can do more testing on mac if you need
I'm not sure what's going on with the Cargo.lock format. I can't find anything important that has changes with respect to main.
Bravo ! would you like to do a release now? :)
Yes, I'll start working on it!