Changeset 446 for ondir

Show
Ignore:
Timestamp:
08/13/07 20:19:03 (1 year ago)
Author:
athomas
Message:

On Dir: Added final clause.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ondir/trunk/conf.c

    r431 r446  
    7171 
    7272                                /* read stuff */ 
    73                                 if (!(tok = strtok(buffer, " \t")) || (strcmp(tok, "enter") && strcmp(tok, "leave"))) 
    74                                         fatal("%s:%i: expected enter or leave", file, line); 
     73                                tok = strtok(buffer, " \t"); 
     74                                if (!tok) 
     75                                        fatal("%s:%i: unexpected end of line", file, line); 
     76 
     77                                if (!strcmp(tok, "final")) { 
     78                                        current->final = 1; 
     79                                        tok = strtok(NULL, " \t"); 
     80                                } 
     81 
     82                                if (strcmp(tok, "enter") && strcmp(tok, "leave")) 
     83                                        fatal("%s:%i: line should start with final, enter or leave", file, line); 
    7584 
    7685                                if (!strcmp(tok, "enter")) 
  • ondir/trunk/conf.h

    r333 r446  
    1818struct odpath_t { 
    1919        const char **paths, *content; 
    20         int npaths
     20        int npaths, final
    2121        pathtype_t type; 
    2222        struct odpath_t *next; 
  • ondir/trunk/ondir.1

    r333 r446  
    11.\" ondir is licensed under the GPL, version 2. A copy of the GPL should have been distributed with the source in the file COPYING 
    2 .TH "ondir" "1" "0.2.0" "Alec Thomas" "Shell utility" 
     2.TH "ondir" "1" "0.2.3" "Alec Thomas" "Shell utility" 
    33.SH "NAME" 
    44.LP  
     
    3636# Comment 
    3737.br  
    38 enter \fB<path>[:<path>[:...]]\fR 
     38[final] enter \fB<path>[:<path>[:...]]\fR 
    3939.br  
    4040        \fB<shell script body>\fR 
    4141.br  
    42 leave \fB<path>[:<path>[:...]]\fR 
     42[final] leave \fB<path>[:<path>[:...]]\fR 
    4343.br  
    4444        \fB<shell script body>\fR 
    4545.LP 
    4646Any line with leading whitespace is assumed to belong to the last valid enter or leave section. 
     47.LP 
     48\fBfinal\fB indicates that the section will be the last one executed for the matching directory. Directories further down the hierarchy will still be matched. 
    4749.LP 
    4850\fB<path>\fR is the path to match. Regular expression support has been included since version 0.2.1 thanks to Arvind (?). A path must match completely to be considered a match. Because : is the path delimiter, it can not be used in any regular expressions. 
  • ondir/trunk/ondir.c

    r445 r446  
    8282        struct odpath_t *p; 
    8383 
    84                 for (p = find_path(NULL, working, PT_LEAVE, match); p; p = find_path(p, working, PT_LEAVE, match)) { 
     84                for (p = find_path(NULL, working, PT_LEAVE, match); p; 
     85                         p = find_path(p, working, PT_LEAVE, match)) { 
    8586                char *sub; 
    8687 
     
    108109                        printf("%s\n", sub); 
    109110                        free(sub); 
     111                        if (p->final) 
     112                                break; 
    110113                } 
    111114#ifdef USE_ONENTERLEAVE 
     
    130133                strncpy(working, dst, len); 
    131134                working[len] = 0; 
    132                 for (p = find_path(NULL, working, PT_ENTER, match); p; p = find_path(p, working, PT_ENTER, match)) { 
     135                for (p = find_path(NULL, working, PT_ENTER, match); p; 
     136                         p = find_path(p, working, PT_ENTER, match)) { 
    133137                char *sub; 
    134138                int i = 0; 
     
    157161                        printf("%s", sub); 
    158162                        free(sub); 
     163                        if (p->final) 
     164                                break; 
    159165                } 
    160166#ifdef USE_ONENTERLEAVE 
  • ondir/trunk/ondirrc.eg

    r333 r446  
    88 
    99# Back to normal 
    10 leave /opt/music:/opt/movies 
     10final leave /opt/music:/opt/movies 
    1111        umask $OLDUMASK 
     12        unset OLDUMASK