From 4c3736eb368fa106dfa6c29a1794aeb1d4c9a1de Mon Sep 17 00:00:00 2001 From: Jonas Maier Date: Tue, 12 May 2026 21:40:56 +0200 Subject: prevent warnings in release build --- src/run/builtin.rs | 109 +++++++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 50 deletions(-) (limited to 'src/run/builtin.rs') diff --git a/src/run/builtin.rs b/src/run/builtin.rs index c8224c0..b731b10 100644 --- a/src/run/builtin.rs +++ b/src/run/builtin.rs @@ -111,31 +111,6 @@ impl Builtin for clear { } } -/// restart shell -#[derive(Copy, Clone)] -pub struct re; -impl Builtin for re { - fn name(&self) -> &str { - "re" - } - - fn special(&mut self, session: Arc>, _args: &[BString]) { - session.lock().unwrap().raw_disable(); - crate::reload::begin_reload(); - session.lock().unwrap().raw_enable(); // something went wrong, let's restore raw mode - } - - fn io( - &self, - _session: Arc>, - _args: &[BString], - _stdin: &mut dyn Read, - _stdout: &mut dyn Write, - ) -> Result { - Ok(()) - } -} - #[derive(Copy, Clone)] pub struct Sink { name: &'static str, @@ -556,31 +531,6 @@ impl Builtin for unalias { } } -#[derive(Copy, Clone)] -pub struct debug; -impl Builtin for debug { - fn name(&self) -> &str { - "debug" - } - - fn io( - &self, - session: Arc>, - args: &[BString], - _stdin: &mut dyn Read, - stdout: &mut dyn Write, - ) -> Result { - let mut se = session.lock().unwrap(); - for arg in args { - match &arg[..] { - b"keys" | b"keystrokes" => se.debug_keystrokes = !se.debug_keystrokes, - _ => writeln!(stdout, "debug: unknown option {}", arg.escape_ascii())?, - } - } - Ok(()) - } -} - #[derive(Copy, Clone)] pub struct terminfo; impl Builtin for terminfo { @@ -988,3 +938,62 @@ impl Builtin for export { Ok(()) } } + +#[cfg(debug_assertions)] +mod dbg { + use super::*; + + #[derive(Copy, Clone)] + pub struct debug; + + impl Builtin for debug { + fn name(&self) -> &str { + "debug" + } + + fn io( + &self, + session: Arc>, + args: &[BString], + _stdin: &mut dyn Read, + stdout: &mut dyn Write, + ) -> Result { + let mut se = session.lock().unwrap(); + for arg in args { + match &arg[..] { + b"keys" | b"keystrokes" => se.debug_keystrokes = !se.debug_keystrokes, + _ => writeln!(stdout, "debug: unknown option {}", arg.escape_ascii())?, + } + } + Ok(()) + } + } + + /// restart shell + #[derive(Copy, Clone)] + pub struct re; + impl Builtin for re { + fn name(&self) -> &str { + "re" + } + + fn special(&mut self, session: Arc>, _args: &[BString]) { + session.lock().unwrap().raw_disable(); + crate::reload::begin_reload(); + session.lock().unwrap().raw_enable(); // something went wrong, let's restore raw mode + } + + fn io( + &self, + _session: Arc>, + _args: &[BString], + _stdin: &mut dyn Read, + _stdout: &mut dyn Write, + ) -> Result { + Ok(()) + } + } +} + +#[cfg(debug_assertions)] +pub use dbg::{debug, re}; -- cgit v1.2.3