Closed gadenbuie closed 3 years ago
Garrick, thanks for reporting this issue. I agree your proposed solution is better behavior in all cases. I'll need to review a little more closely, and might ask you to submit the patch against the development branch (although please wait as it is currently out of date...).
Garrick, this looks good to me. Will you change the target branch to the development branch? Also, if you're up for it go ahead and add a NEWS entry.
I ran into this issue in a situation where we're evaluating semi-trusted user input where we want to be careful that the user cannot change external settings. As a result, we're carefully scrubbing and restoring the state of global option after evaluating the user input. Unfortunately, this led me to an issue where
diffobj
(and alsofansi
) set global options on load that may later removed and break package functionality.Here's a simple reprex. Run a function that attaches diffobj, but where options are protected.
Yes, the options are protected a little aggressively, restoring unset options to their original state...
with the side-effect of removing the
diffobj.max.diffs
option...breaking any subsequent call to
ses()
.(Something similar happens for
diffobj.warn
.)The solution I'm proposing is to fall back to the internal diffobj default value in
gdo()
. I think this is reasonable since I think it doesn't change the intended behavior and it matches the expectations described in the documentation:I recognize I haven't completely though through all of the implications, if there are any broader problems please feel free to treat this PR as an issue report 😄