GothenburgBitFactory / GothenburgBitFactory/taskwarrior

[TW-1908] STDERR potentially abused for status messages while running 'task sync'

Open
#1,921 6 comments 0 reactions 0 assignees View on GitHub
type:bug
Dominant language
C++
Stars
6.1k
Forks
423
Avg merge
1d 19h
Merged PRs (30d)
11

Description

_rjc on 2017-04-19T04:34:00Z says:_

Hi,

Task is potentially abusing STDERR for some of its status messages.
This issue is easily observed by running "task sync" from cron(8). Namely, when I run it from said cron(8) I would very much like to get an email only when there's a real issue running the above command. Obviously, I can just redirect STDOUT to /dev/null:

task sync > /dev/null

However, I still get this message on STDERR output:

Sync successful. No changes.

OK, let's try the other way around - redirect STDERR to /dev/null:

task sync 2> /dev/null

The problem with that approach is that I get another message, this time to STDOUT:

Syncing with my.task.server:53589

Sure, I can redirect *both* to /dev/null like so:

task sync > /dev/null 2>&1

and that's what I'm currently using but, in case there's a real error (i.e. error code != 0), I won't see it as I already redirected *both* STDOUT and STDERR to /dev/null, to merely silence the status messages of 'task sync'.

Currently I'm running something like this:

task sync > /dev/null 2>&1 || echo "Something went wrong - run 'task sync' again to see what it was."

I understand that STDERR was probably chosen for a reason but it feels like one needs to jump through quite a number of hoops to get 'task sync' working from cron(8) without emails for every single sync *and* with emails *only* when there's a failure.
It's never too late to change it! :^)

Regards,

Raf

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.