highlight test: use /usr/bin/env instead of /bin/cat

/bin/cat doesn't exist on e.g. nixos, which only has /bin/sh and
/usr/bin/env.

/usr/bin/env should at least exist on more systems than /bin/cat

Part of #12544
This commit is contained in:
Noah Hellman
2026-03-13 17:24:46 +01:00
committed by Johannes Altmanninger
parent a0d8d27f45
commit 5c042575b0

View File

@@ -1431,8 +1431,9 @@ macro_rules! validate {
let local_mode = EnvSetMode::new_at_early_startup(EnvMode::LOCAL);
vars.set_one(L!("CDPATH"), local_mode, L!("./cdpath-entry").to_owned());
vars.set_one(L!("VARIABLE_IN_COMMAND"), local_mode, L!("a").to_owned());
vars.set_one(L!("VARIABLE_IN_COMMAND2"), local_mode, L!("at").to_owned());
// NOTE n, nv are suffix of /usr/bin/env
vars.set_one(L!("VARIABLE_IN_COMMAND"), local_mode, L!("n").to_owned());
vars.set_one(L!("VARIABLE_IN_COMMAND2"), local_mode, L!("nv").to_owned());
let _cleanup = ScopeGuard::new((), |_| {
vars.remove(L!("VARIABLE_IN_COMMAND"), EnvSetMode::default());
@@ -1773,24 +1774,25 @@ macro_rules! validate {
("VERSION", fg(HighlightRole::operat), ns),
);
// NOTE: we assume /usr/bin/env exists on the system here
validate!(
("/bin/ca", fg(HighlightRole::command), ns),
("/usr/bin/en", fg(HighlightRole::command), ns),
("*", fg(HighlightRole::operat), ns)
);
validate!(
("/bin/c", fg(HighlightRole::command), ns),
("/usr/bin/e", fg(HighlightRole::command), ns),
("*", fg(HighlightRole::operat), ns)
);
validate!(
("/bin/c", fg(HighlightRole::command), ns),
("/usr/bin/e", fg(HighlightRole::command), ns),
("{$VARIABLE_IN_COMMAND}", fg(HighlightRole::operat), ns),
("*", fg(HighlightRole::operat), ns)
);
validate!(
("/bin/c", fg(HighlightRole::command), ns),
("/usr/bin/e", fg(HighlightRole::command), ns),
("$VARIABLE_IN_COMMAND2", fg(HighlightRole::operat), ns)
);