Bug: Fixed bug where 'rc.allow.empty.filter' was not behaving properly

- Thanks to Scott Kostyshak.
This commit is contained in:
Paul Beckingham 2016-01-23 15:21:44 -05:00
parent c023e3e721
commit 406f77efe2
2 changed files with 21 additions and 15 deletions

View file

@ -59,6 +59,8 @@
- Numerous performance improvements. Taskwarrior 2.5.1 is between X% and - Numerous performance improvements. Taskwarrior 2.5.1 is between X% and
Y% faster than 2.5.0 when running various commands. Y% faster than 2.5.0 when running various commands.
- New formatting specifier 'relative' for columns of Date type was introduced. - New formatting specifier 'relative' for columns of Date type was introduced.
- Fixed bug where 'rc.allow.empty.filter' was not behaving properly (thanks to
Scott Kostyshak).
- Improved OpenBSD support (thanks to Kent R. Spillner). - Improved OpenBSD support (thanks to Kent R. Spillner).
------ current release --------------------------- ------ current release ---------------------------

View file

@ -273,27 +273,31 @@ void Filter::safety ()
{ {
if (_safety) if (_safety)
{ {
bool readonly = true;
bool filter = false;
for (auto& a : context.cli2._args) for (auto& a : context.cli2._args)
{ {
if (a.hasTag ("CMD")) if (a.hasTag ("CMD") &&
{ ! a.hasTag ("READONLY"))
if (! a.hasTag ("READONLY")) readonly = false;
{
if (! context.config.getBoolean ("allow.empty.filter"))
throw std::string (STRING_TASK_SAFETY_ALLOW);
// If user is willing to be asked, this can be avoided. if (a.hasTag ("FILTER"))
if (context.config.getBoolean ("confirmation") && filter = true;
confirm (STRING_TASK_SAFETY_VALVE)) }
return;
// Sounds the alarm. if (! readonly &&
throw std::string (STRING_TASK_SAFETY_FAIL); ! filter)
} {
if (! context.config.getBoolean ("allow.empty.filter"))
throw std::string (STRING_TASK_SAFETY_ALLOW);
// CMD was found. // If user is willing to be asked, this can be avoided.
if (context.config.getBoolean ("confirmation") &&
confirm (STRING_TASK_SAFETY_VALVE))
return; return;
}
// Sound the alarm.
throw std::string (STRING_TASK_SAFETY_FAIL);
} }
} }
} }