From 6ff9afc346cf592c4aa97a8b7bf5f9939ed5c687 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Fri, 15 Dec 2017 21:24:40 -0800 Subject: [PATCH] bench/fasd: workaround fasd 'empty history' bug Fasd, in some some bash configuratoins, fails in its prompt function if the history file is empty. This is due to https://github.com/clvv/fasd/blob/90b531a5daaa545c74c7d98974b54cbdb92659fc/fasd#L127-L130 implicitly assuming 'history 1' returns something. Note, this bug appears to occur on bash 4.3+ubuntu but not 4.4+fedora. As such, it happens on travis-ci even though it doesn't impact my local environment. It seems possible that travis's bash is setting 'shift_verbose' leading to this, but frankly now that it works I'm going to pretend none of this happened. --- tests/src/harness/autojumpers/fasd.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/src/harness/autojumpers/fasd.rs b/tests/src/harness/autojumpers/fasd.rs index eaa9e7d6..50da1203 100644 --- a/tests/src/harness/autojumpers/fasd.rs +++ b/tests/src/harness/autojumpers/fasd.rs @@ -19,8 +19,18 @@ impl Autojumper for Fasd { fn init_for(&self, shell: &Shell) -> String { match shell { - &Shell::Bash | &Shell::Zsh => { - format!(r#"eval "$({} --init posix-alias {}-hook)""#, self.bin_path(), shell.name()) + &Shell::Bash => { + format!(r#" +# Ensure history is not blank; fasd grabs commands to process from history +# (https://github.com/clvv/fasd/blob/90b531a5daaa545c74c7d98974b54cbdb92659fc/fasd#L127-L130) +# and, if history is empty, will error out +echo "echo hello world" >> ~/.bash_history + +eval "$({} --init posix-alias bash-hook)" +"#, self.bin_path()) + } + &Shell::Zsh => { + format!(r#"eval "$({} --init posix-alias zsh-hook)""#, self.bin_path()) } &Shell::Conch => unimplemented!(), }