rcaloras / bash-preexec

⚡ preexec and precmd functions for Bash just like Zsh.
MIT License
865 stars 94 forks source link

sed -E does not work with older versions of sed #87

Closed steinarvk closed 5 years ago

steinarvk commented 5 years ago

This is an issue introduced with my earlier commit 1c9db27 . It uses the -E flag for sed (--regexp-extended), but this is not supported by every version of sed. Specifically I've observed it to fail on GNU sed 4.1.3.

It's probably better to use a variant of d630's suggestion from #79 .

d630 commented 5 years ago

I'm no regex-pro, but what about:

h1=$(history -s foo$'\n'bar$'\n'lich; HISTTIMEFORMAT= history 1);

<<< "$h1" sed '1 s/^ *[0-9]\{1,\}[\* ] //';

<<< "$h1" sed '1 s/^ *[0-9]*[\* ] //';
rcaloras commented 5 years ago

@steinarvk thanks for reporting! Can one of you guys submit the PR?

dimo414 commented 5 years ago

I went with 1 s/^ *[0-9]\+[* ] // in http://hg.mwdiamond.com/prompt.gem/commits/f1f67721 - the only difference between it and the variant in 1c9db27 is the \-escaped + symbol. I should have called out the risk of -E in the PR but I didn't want to be a stickler :) I can send this change if we want.

rcaloras commented 5 years ago

@dimo414 that'd be awesome, please do! :pray: