Opened 18 years ago

Closed 18 years ago

#1113 closed patch (wontfix)

mythrename.pl - less verbose code for the --verbose option

Reported by: sphery <mtdean@…> Owned by: xris
Priority: trivial Milestone: unknown
Component: mythtv Version:
Severity: low Keywords:
Cc: Ticket locked: no

Description

Attached patch makes "--verbose" output generation code less verbose, removing the need for

if (defined($verbose)) {
    print ... ;
}

code blocks by simply redirecting STDOUT to devnull() when "--verbose" is not specified. Errors are still printed as before because die sends messages to STDERR.

I used File::Spec's devnull() function for portability, but if you prefer just assuming "/dev/null" (and removing the "use File::Spec;"), it should work just as well any place the script is likely to be executed. However, since File::Spec is a standard module, it probably doesn't hurt to use the devnull() function.

The patch does assume we'll only ever need one level of verbose output, but I think for a contributed script, this is a safe assumption. :) Oh, and it's quite possible there's a prettier (more Perl-like) way of opening STDOUT with the devnull() function than concatenating the "> " to the function's output, but I couldn't find anything.

Attachments (1)

mythtv-mythrename-verbose.patch (2.0 KB) - added by sphery <mtdean@…> 18 years ago.
patch

Download all attachments as: .zip

Change History (2)

Changed 18 years ago by sphery <mtdean@…>

patch

comment:1 Changed 18 years ago by xris

Resolution: wontfix
Status: newclosed

If I add this in, and I later decide to make it have SOME kind of output in non-verbose mode, this will get messy. Easier to just leave it as it is now, or maybe someday write a vprint() function that only prints if verbose is enabled.

Note: See TracTickets for help on using tickets.