Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix redirect stdin command for fish shell (#39963)

Kevin Rambaud63032f6c665c
diff --git a/crates/task/src/shell_builder.rs b/crates/task/src/shell_builder.rs
index 520c04e367b..d6091997b27 100644
--- a/crates/task/src/shell_builder.rs
+++ b/crates/task/src/shell_builder.rs
@@ -87,9 +87,12 @@ impl ShellBuilder {
});
if self.redirect_stdin {
match self.kind {
+ ShellKind::Fish => {
+ combined_command.insert_str(0, "begin; ");
+ combined_command.push_str("; end </dev/null");
+ }
ShellKind::Posix
| ShellKind::Nushell
- | ShellKind::Fish
| ShellKind::Csh
| ShellKind::Tcsh
| ShellKind::Rc
@@ -159,4 +162,17 @@ mod test {
assert_eq!(program, "nu");
assert_eq!(args, vec!["-i", "-c", "(echo nothing) </dev/null"]);
}
+
+ #[test]
+ fn redirect_stdin_to_dev_null_fish() {
+ let shell = Shell::Program("fish".to_owned());
+ let shell_builder = ShellBuilder::new(&shell);
+
+ let (program, args) = shell_builder
+ .redirect_stdin_to_dev_null()
+ .build(Some("echo".into()), &["test".to_string()]);
+
+ assert_eq!(program, "fish");
+ assert_eq!(args, vec!["-i", "-c", "begin; echo test; end </dev/null"]);
+ }
}