fix: use procsub in bash since termux has no stdin (#241)

This commit is contained in:
Bruno Bigras 2019-08-27 03:02:52 -04:00 committed by Kevin Song
parent f61e7e2f87
commit fa2d1c05a6

View File

@ -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") => {