Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/input.c

    r1b20da0 ra35b458  
    7171                return ENOMEM;
    7272        token_t *tokens = tokens_buf;
    73        
     73
    7474        char *cmd[WORD_MAX];
    7575        errno_t rc = EOK;
     
    8989                goto finit;
    9090        }
    91        
     91
    9292        size_t tokens_length;
    9393        rc = tok_tokenize(&tok, &tokens_length);
     
    9595                goto finit;
    9696        }
    97        
     97
    9898        if (tokens_length > 0 && tokens[0].type == TOKTYPE_SPACE) {
    9999                tokens++;
    100100                tokens_length--;
    101101        }
    102        
     102
    103103        if (tokens_length > 0 && tokens[tokens_length-1].type == TOKTYPE_SPACE) {
    104104                tokens_length--;
    105105        }
    106        
     106
    107107        /* Until full support for pipes is implemented, allow for a simple case:
    108108         * [from <file> |] command [| to <file>]
     
    121121                }
    122122        }
    123        
     123
    124124        unsigned int cmd_token_start = 0;
    125125        unsigned int cmd_token_end = tokens_length;
    126        
     126
    127127        processed_pipes = 0;
    128        
     128
    129129        /* Check if the first part (from <file> |) is present */
    130130        if (pipe_count > 0 && (pipe_pos[0] == 3 || pipe_pos[0] == 4) && str_cmp(tokens[0].text, "from") == 0) {
     
    134134                processed_pipes++;
    135135        }
    136        
     136
    137137        /* Check if the second part (| to <file>) is present */
    138138        if ((pipe_count - processed_pipes) > 0 &&
     
    146146                processed_pipes++;
    147147        }
    148        
     148
    149149        if (processed_pipes != pipe_count) {
    150150                print_pipe_usage();
     
    152152                goto finit;
    153153        }
    154        
     154
    155155        /* Convert tokens of the command to string array */
    156156        unsigned int cmd_pos = 0;
     
    161161        }
    162162        cmd[cmd_pos++] = NULL;
    163        
     163
    164164        if (cmd[0] == NULL) {
    165165                print_pipe_usage();
     
    167167                goto finit;
    168168        }
    169        
     169
    170170        iostate_t new_iostate = {
    171171                .stdin = stdin,
     
    173173                .stderr = stderr
    174174        };
    175        
     175
    176176        FILE *from = NULL;
    177177        FILE *to = NULL;
    178        
     178
    179179        if (redir_from) {
    180180                from = fopen(redir_from, "r");
     
    186186                new_iostate.stdin = from;
    187187        }
    188        
    189        
     188
     189
    190190        if (redir_to) {
    191191                to = fopen(redir_to, "w");
     
    203203                rc = EINVAL;
    204204        }
    205        
     205
    206206finit_with_files:
    207207        if (from != NULL) {
     
    211211                fclose(to);
    212212        }
    213        
     213
    214214finit:
    215215        if (NULL != usr->line) {
     
    230230        printf("from filename | command ... | to filename\n");
    231231        printf("command ... | to filename\n");
    232        
     232
    233233}
    234234
     
    236236{
    237237        int id = 0;
    238        
     238
    239239        /* We have rubbish */
    240240        if (NULL == cmd[0]) {
    241241                return CL_ENOENT;
    242242        }
    243        
     243
    244244        /* Is it a builtin command ? */
    245245        if ((id = (is_builtin(cmd[0]))) > -1) {
    246246                return run_builtin(id, cmd, usr, new_iostate);
    247247        }
    248        
     248
    249249        /* Is it a module ? */
    250250        if ((id = (is_module(cmd[0]))) > -1) {
     
    260260        char *str;
    261261        errno_t rc;
    262        
     262
    263263        tinput_set_prompt(tinput, usr->prompt);
    264264
Note: See TracChangeset for help on using the changeset viewer.