fix(cmd)!: always use sh for all command executions

This commit is contained in:
Loric ANDRE 2026-01-14 18:47:39 +01:00
parent 3dc64cfb90
commit fe3f470b8a
3 changed files with 6 additions and 7 deletions

View file

@ -7,10 +7,10 @@ generate-files:
cargo run -- --shell zsh > ./shell/completion.zsh
cargo run -- --shell fish > ./shell/completion.fish
changelog:
git cliff -o CHANGELOG.md
changelog version:
git cliff -o CHANGELOG.md -t 'v{{ version }}'
release version: (bump-version version) generate-files changelog
release version: (bump-version version) generate-files (changelog version)
cargo generate-lockfile
git add CHANGELOG.md Cargo.lock Cargo.toml man/ shell/
git commit -m 'release: v{{ version }}'

View file

@ -1,6 +1,5 @@
//! Helper utilities for converting input sources into skim item streams.
use std::env;
use std::error::Error;
use std::io::{BufRead, BufReader};
use std::process::{Child, Command, Stdio};
@ -369,9 +368,8 @@ impl CommandCollector for SkimItemReader {
type CommandOutput = (Option<Child>, Box<dyn BufRead + Send>);
fn get_command_output(cmd: &str, send_error: bool) -> Result<CommandOutput, Box<dyn Error>> {
let shell = env::var("SHELL").unwrap_or_else(|_| "sh".to_string());
let (reader, writer) = std::io::pipe()?;
let mut sh = Command::new(shell);
let mut sh = Command::new("sh");
let command = sh.arg("-c").arg(cmd).stdout(writer.try_clone()?);
if send_error {
trace!("redirecting stderr to the output");

View file

@ -153,6 +153,7 @@ sk_test!(opt_nth_oob, "f1,f2,f3,f4", &["--delimiter", ",", "--nth", "5"], {
@capture[1] contains("0/1");
});
sk_test!(opt_nth_neg_1, "f1,f2,f3,f4", &["--delimiter", ",", "--nth=-1"], {
@capture[0] starts_with(">");
@keys Str("4");
@capture[0] eq("> 4");
@capture[1] contains("1/1");
@ -586,7 +587,7 @@ sk_test!(opt_pre_select_file, "a\\nb\\nc", &[], tmux => {
tmux.until(|l| l.len() > 4 && l[2] == "> a" && l[3].trim() == ">b" && l[4].trim() == ">c")?;
});
sk_test!(opt_no_clear_if_empty, @cmd "echo -ne 'a\\nb\\nc'", &["-i", "--no-clear-if-empty", "-c", "'echo -ne {}'"], {
sk_test!(opt_no_clear_if_empty, @cmd "echo -ne 'a\\nb\\nc'", &["-i", "--no-clear-if-empty", "-c", "'printf {}'"], {
@capture[0] trim().eq("c>");
@keys Str("xxxx");