Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
steinarvk opened this issue Dec 20, 2018 · 4 comments
Closed

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

steinarvk opened this issue Dec 20, 2018 · 4 comments

Comments

@steinarvk
Copy link
Contributor

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
Copy link
Contributor

d630 commented Dec 21, 2018

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
Copy link
Owner

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

@dimo414
Copy link
Collaborator

dimo414 commented Dec 27, 2018

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
Copy link
Owner

@dimo414 that'd be awesome, please do! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants