Re: [gentoo-portage-dev] Re: RFC: [QA] notice with 'failed' seds [was PATCH: eapply drop -s option]
On 12/16/19 12:27 AM, Michał Górny wrote: > On Sun, 2019-12-15 at 13:29 -0800, Zac Medico wrote: >> On 12/13/19 2:12 PM, Michael 'veremitz' Everitt wrote: >>> On 13/12/19 20:36, Michał Górny wrote [excerpted]: Is this really an argument for or *against* it? Developers are entirely capable of keeping seds that do nothing for years, as well as patches that -- while apparently applying correctly -- are entirely meaningless. >>> >>> >>> I think there is some merit in some kind of feedback when sed's are doing >>> nothing, although how feasible it is to generate any useful feedback I >>> can't say. I wouldn't say it needs to explicitly fail or make lots of >>> noise, just an info message that could prompt some further investigation. >>> >> >> It's possible to implement a sed wrapper that detects file arguments for >> -i/--in-place mode, and compares file content before and after the sed call. >> >> There are also ways to make sed exit with an error but that won't be as >> easy to use as a sed wrapper: >> >> https://stackoverflow.com/questions/15965073/return-code-of-sed-for-no-match/15966279 > > Don't forget that there could be valid cases for sed not changing > a file. Not to mention corner cases where a working replacement results > in no change, e.g.: > > # yuck! > sed -i -e "s^-O2^${CFLAGS}^" ... > Still, I imagine the number of false positives for a QA warning based on this would be relatively low. -- Thanks, Zac signature.asc Description: OpenPGP digital signature
Re: [gentoo-portage-dev] Re: RFC: [QA] notice with 'failed' seds [was PATCH: eapply drop -s option]
On Sun, 2019-12-15 at 13:29 -0800, Zac Medico wrote: > On 12/13/19 2:12 PM, Michael 'veremitz' Everitt wrote: > > On 13/12/19 20:36, Michał Górny wrote [excerpted]: > > > Is this really an argument for or *against* it? Developers are entirely > > > capable of keeping seds that do nothing for years, as well as patches > > > that -- while apparently applying correctly -- are entirely meaningless. > > > > > > I think there is some merit in some kind of feedback when sed's are doing > > nothing, although how feasible it is to generate any useful feedback I > > can't say. I wouldn't say it needs to explicitly fail or make lots of > > noise, just an info message that could prompt some further investigation. > > > > It's possible to implement a sed wrapper that detects file arguments for > -i/--in-place mode, and compares file content before and after the sed call. > > There are also ways to make sed exit with an error but that won't be as > easy to use as a sed wrapper: > > https://stackoverflow.com/questions/15965073/return-code-of-sed-for-no-match/15966279 Don't forget that there could be valid cases for sed not changing a file. Not to mention corner cases where a working replacement results in no change, e.g.: # yuck! sed -i -e "s^-O2^${CFLAGS}^" ... -- Best regards, Michał Górny signature.asc Description: This is a digitally signed message part
[gentoo-portage-dev] Re: RFC: [QA] notice with 'failed' seds [was PATCH: eapply drop -s option]
On 12/13/19 2:12 PM, Michael 'veremitz' Everitt wrote: > On 13/12/19 20:36, Michał Górny wrote [excerpted]: >> >> Is this really an argument for or *against* it? Developers are entirely >> capable of keeping seds that do nothing for years, as well as patches >> that -- while apparently applying correctly -- are entirely meaningless. > > > I think there is some merit in some kind of feedback when sed's are doing > nothing, although how feasible it is to generate any useful feedback I > can't say. I wouldn't say it needs to explicitly fail or make lots of > noise, just an info message that could prompt some further investigation. > It's possible to implement a sed wrapper that detects file arguments for -i/--in-place mode, and compares file content before and after the sed call. There are also ways to make sed exit with an error but that won't be as easy to use as a sed wrapper: https://stackoverflow.com/questions/15965073/return-code-of-sed-for-no-match/15966279 -- Thanks, Zac signature.asc Description: OpenPGP digital signature