aboutsummaryrefslogtreecommitdiffstats
path: root/src/run
diff options
context:
space:
mode:
authorJonas Maier <jonas@x77.dev>2026-05-12 21:40:56 +0200
committerJonas Maier <jonas@x77.dev>2026-05-12 21:40:56 +0200
commit4c3736eb368fa106dfa6c29a1794aeb1d4c9a1de (patch)
tree59583554c15176910fd2ae75fd2fb94c7e6dbe72 /src/run
parentdbbec673e5b18625f95627b25e9e2a2a0d300acd (diff)
downloadpish-4c3736eb368fa106dfa6c29a1794aeb1d4c9a1de.tar.gz
prevent warnings in release build
Diffstat (limited to 'src/run')
-rw-r--r--src/run/builtin.rs109
1 files changed, 59 insertions, 50 deletions
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<Mutex<Session>>, _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<Mutex<Session>>,
- _args: &[BString],
- _stdin: &mut dyn Read,
- _stdout: &mut dyn Write,
- ) -> Result {
- Ok(())
- }
-}
-
#[derive(Copy, Clone)]
pub struct Sink {
name: &'static str,
@@ -557,31 +532,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<Mutex<Session>>,
- 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 {
fn name(&self) -> &str {
@@ -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<Mutex<Session>>,
+ 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<Mutex<Session>>, _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<Mutex<Session>>,
+ _args: &[BString],
+ _stdin: &mut dyn Read,
+ _stdout: &mut dyn Write,
+ ) -> Result {
+ Ok(())
+ }
+ }
+}
+
+#[cfg(debug_assertions)]
+pub use dbg::{debug, re};