diff options
author | Bruno Bigras <bigras.bruno@gmail.com> | 2019-08-27 03:02:52 -0400 |
---|---|---|
committer | Kevin Song <chipbuster@users.noreply.github.com> | 2019-08-27 00:02:52 -0700 |
commit | fa2d1c05a60106958c768870786b9d0502273fbe (patch) | |
tree | 41c8e267bd4da07454a46d5aa40b25eb22d92659 /src | |
parent | f61e7e2f87be484ab817d6ff6e02e1351faab895 (diff) |
fix: use procsub in bash since termux has no stdin (#241)
Diffstat (limited to 'src')
-rw-r--r-- | src/init.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/init.rs b/src/init.rs index fed4be2ff..b7307dbef 100644 --- a/src/init.rs +++ b/src/init.rs @@ -35,10 +35,18 @@ pub fn init_stub(shell_name: &str) -> io::Result<()> { /* This *should* look like the zsh function, but bash 3.2 (MacOS default shell) does not support using source with process substitution, so we use this workaround from https://stackoverflow.com/a/32596626 */ - let script = format!( - "source /dev/stdin <<<\"$(\"{}\" init bash --print-full-init)\"", - starship - ); + let script = { + format!( + r#"if [ "${{BASH_VERSINFO[0]}}" -gt 4 ] +then +source <("{}" init bash --print-full-init) +else +source /dev/stdin <<<"$("{}" init bash --print-full-init)" +fi"#, + starship, starship + ) + }; + Some(script) } Some("zsh") => { |