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

Sed awk grep removal #758

Merged
merged 6 commits into from
Jul 13, 2020
Merged

Conversation

themadprofessor
Copy link
Contributor

@themadprofessor themadprofessor commented Jun 26, 2020

Replace calls to sed, awk, grep, etc with the regex crate where possible.
Currently, don't have access to a machine with Wi-Fi, so those calls have been left in for now.

Closes #725

@themadprofessor themadprofessor changed the title WIP: Sed awk grep removal [WIP] Sed awk grep removal Jun 26, 2020
@themadprofessor
Copy link
Contributor Author

That's the remaining calls replaced.
The regexs for iwctl and nmctl haven't been tested as I don't have a machine with those commands, but they should work.
If someone can test those, that would be great.

@themadprofessor themadprofessor changed the title [WIP] Sed awk grep removal Sed awk grep removal Jun 29, 2020
@ammgws
Copy link
Collaborator

ammgws commented Jul 7, 2020

The fallback logic is broken. I only have iwctl installed and I get:

Error in block 'net': Failed to execute SSID query using iw.

However the previous behaviour was that it didn't fail on iw and instead fell back to the next possible command until it reached iwctl.

@themadprofessor themadprofessor force-pushed the sed-awk-grep-removal branch 2 times, most recently from 7f286e4 to 761bbf0 Compare July 7, 2020 15:25
@themadprofessor
Copy link
Contributor Author

Whoops, good spot. Should be fixed now.

@themadprofessor themadprofessor force-pushed the sed-awk-grep-removal branch 2 times, most recently from d9027b3 to c567086 Compare July 7, 2020 15:38
src/blocks/net.rs Outdated Show resolved Hide resolved
src/blocks/net.rs Show resolved Hide resolved
src/blocks/net.rs Outdated Show resolved Hide resolved
src/blocks/net.rs Outdated Show resolved Hide resolved
@ammgws
Copy link
Collaborator

ammgws commented Jul 9, 2020

Hmm, current master and the below config works fine but pulling in this branch causes it to fail. It shouldn't fail since bitrate isn't specified in the config. I'm sure the bug itself is unrelated to this PR though.

[[block]]
block = "net"
format = "{ssid}"
>./target/debug/i3status-rs test.toml
{"version": 1, "click_events": true}
[[{"background":"#000000","color":"#dc322f","full_text":" Error in block 'net': Failed to execute bitrate query with iw. ","separator":false,"separator_block_width":0}]

Error in block 'net': Failed to execute bitrate query with iw.

@ammgws
Copy link
Collaborator

ammgws commented Jul 13, 2020

OK I see what's going on. Before it would run, for example, `sh -c "ethtool ... | awk ..." and due to the command being piped to awk/sed/etc the exit code was 0 even if ethtool itself was not installed/failed to run. Now that all those pipes to sed/awk are gone and the command is called directly it is failing as it should have done before.

@ammgws ammgws merged commit 4f772bc into greshake:master Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace uses of sed/etc with Rust native regex
2 participants