-
Notifications
You must be signed in to change notification settings - Fork 89
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
feat(stdlib): extract function #587
base: master
Are you sure you want to change the base?
Conversation
Implemented new functions for |
Co-authored-by: Phoenix Himself <[email protected]>
Co-authored-by: Phoenix Himself <[email protected]>
src/std/text.ab
Outdated
let flag = status == 0 then "-r" else "-E" | ||
output = $ echo "{source}" | sed "{flag}" -e "{search}" $ | ||
} else { | ||
output = $ echo "{source}" | sed -e "{search}" $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to use sed -n
(suppress automatic printing), and /.../p
to print matching lines:
...
output = $ echo "{source}" | sed "{flag}" -ne "/{search}/p" $
} else {
output = $ echo "{source}" | sed -ne "/{search}/p" $
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is working as it is now, if I change in that way doesn't work
src/std/text.ab
Outdated
} else { | ||
output = $ echo "{source}" | sed -e "{search}" $ | ||
} | ||
if output == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to return true
if sed
output is not empty:
if output != "" {
return true
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above for reasons why it's still recommended to use if output != ""
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @hdwalters suggestions
I have some doubts about removing |
Co-authored-by: Phoenix Himself <[email protected]>
Co-authored-by: Phoenix Himself <[email protected]>
@Mte90 wrote:
I still can't agree with this; I maintain that calling functions should pass
|
@Ph0enixKM wrote:
We have to escape those operators with basic regex support in I don't think we should do any preprocessing on the string; we can't predict what various flavours of |
However, it occurs to me that we can support any hypothetical move away from |
So I removed the |
src/std/text.ab
Outdated
} else { | ||
output = $ echo "{source}" | sed -e "{search}" $ | ||
} | ||
if output == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above for reasons why it's still recommended to use if output != ""
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thanks!
Ref: #449
So I implemented the extract function in amber, required a new function
contains_multiple