Ticket #8926: 0002-Explain-any-syntax-errors-in-feeds.conf.patch

File 0002-Explain-any-syntax-errors-in-feeds.conf.patch, 1.3 KB (added by kevinoid, 6 years ago)

Patch to print the specific syntax error which occurred

  • scripts/feeds

    From 2c968913a59ae03849d2ae823a5a4a4eb0d1808c Mon Sep 17 00:00:00 2001
    From: Kevin Locke <klocke@digitalenginesoftware.com>
    Date: Tue, 8 Feb 2011 12:35:57 -0700
    Subject: [PATCH 2/2] Explain any syntax errors in feeds.conf
    
    Users will not necessarily know the exact details of the feeds.conf
    syntax, so report the specific cause of a syntax error so they can fix
    it without reading the source of the parsing script.
    
    Signed-off-by: Kevin Locke <klocke@digitalenginesoftware.com>
    ---
     scripts/feeds |   10 ++++++----
     1 files changed, 6 insertions(+), 4 deletions(-)
    
    diff --git a/scripts/feeds b/scripts/feeds
    index da326a0..97bdd38 100755
    a b sub parse_config() { 
    4646                my @line = split /\s+/, $_, 3; 
    4747                my @src; 
    4848 
    49                 my $valid = 1; 
    50                 $line[0] =~ /^src-\w+$/ or $valid = 0; 
    51                 $line[1] =~ /^\w+$/ or $valid = 0; 
     49                $line[0] =~ /^src-\w+$/ 
     50                        or die "Syntax error in feeds.conf, line: $line" . 
     51                                "Lines must start with src-\\w+"; 
     52                $line[1] =~ /^\w+$/ 
     53                        or die "Syntax error in feeds.conf, line: $line" . 
     54                                "Feed names must contain only letters"; 
    5255                @src = split /\s+/, $line[2]; 
    53                 $valid or die "Syntax error in feeds.conf, line: $line\n"; 
    5456 
    5557                $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n"; 
    5658                $name{$line[1]} = 1;