nmh-workers
[Top] [All Lists]

Re: folder-specific defaults?

2002-06-28 11:04:29
Earl Hood <earl(_at_)earlhood(_dot_)com> wrote:

Now what are the odds that the other options will have an argument
that starts with a '+'?

Long odds, I'd say.

Well, you either have something that is not perfect, but simple, and
will probably work for all uses that you will ever do, or do something
more complicated to handle all possible cases, even if you will never
excercise those cases.

Ehh...not that complicated, I don't think:

    #!/usr/bin/perl
    # Author: Earl Hood, <earl(_at_)earlhood(_dot_)com>
    # Tweaked: Scott Blachowicz <scott(_at_)sabami(_dot_)seaslug(_dot_)org>

    # Pathname to MH/nmh scan program
    my $nmh_scan = -x '/usr/local/bin/scan' ? '/usr/local/bin/scan' : 
'/usr/bin/scan';

    my %has_arg = (
      'form' => 1, 'format' => 1, 'forma' => 1, 'width' => 1, 'file' => 1,
    );

    # Determine which folder we are scanning
    my $folder;
    my $skip;
    foreach (@ARGV) {
      $skip = 0, next if $skip;
      $skip = 1, next if /^-(.*)/ && $has_arg{$1};

      if (/^\+/) {
        $folder = $_;
        last;
      }
    }
    my $mhpath = ($folder) ? `mhpath $folder` : `mhpath`;
    chomp $mhpath;

    # Generate pathname to folder-specific scan format file
    my $scan_format = join('/', $mhpath, 'scan.format');

    # Execute nmh scan
    if (-e $scan_format) {
      exec $nmh_scan, '-form', $scan_format, @ARGV;
    } else {
      exec $nmh_scan, @ARGV;
    }

Just skip over the args to other args.  Anything that's left ought to be a 
folder
name, I think.

I need to go try working with those patches...or get back to work here :).

Scott


<Prev in Thread] Current Thread [Next in Thread>