Created
January 20, 2026 02:56
-
-
Save gnachman/1aee2d5f440bc5b82e1db405ef67195f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::env; | |
| pub fn term_features_has_p() -> bool { | |
| let Ok(value) = env::var("TERM_FEATURES") else { | |
| return false; | |
| }; | |
| let mut current = String::new(); | |
| for ch in value.chars() { | |
| if !ch.is_ascii_alphanumeric() { | |
| // Stop at first non-alphanumeric per spec | |
| break; | |
| } | |
| if ch.is_ascii_uppercase() { | |
| if current == "P" { | |
| return true; | |
| } | |
| current.clear(); | |
| current.push(ch); | |
| } else { | |
| current.push(ch); | |
| } | |
| } | |
| current == "P" | |
| } | |
| fn main() { | |
| if term_features_has_p() { | |
| println!("PROGRESS feature detected"); | |
| } else { | |
| println!("PROGRESS feature not detected"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment