Changeset 08bd04c in mainline


Ignore:
Timestamp:
2018-11-30T05:48:10Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
02c6dcc
Parents:
598e3a7
Message:

some formatting issue; making alias more robust for the unexpected; correcting help message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/alias/alias.c

    r598e3a7 r08bd04c  
    6363                free(data->value);
    6464                data->value = str_dup(value);
    65 
    66                 printf("%s: update value ", cmdname);
    67         }else {
     65        } else {
    6866                //add new value
    6967                alias_t* data = (alias_t*)calloc(1, sizeof(alias_t));
     
    7270
    7371                odict_insert(&data->odict, &alias_dict, NULL);
    74 
    75 
    76                 printf("%s: insert value ", cmdname);
    7772        }
    78 
    79         printf(alias_format, name, value);
    8073}
    8174
     
    8780void help_cmd_alias(unsigned int level)
    8881{
    89         printf("Set a new alias with \"alias hex='cat --hex'\". Display an alias with \"alias hex\". List all alias by passing no argument.\n");
     82        printf("`%s' sets an alias, displays an alias or lists all aliases\n", cmdname);
    9083        return;
    9184}
     
    10396        size_t i;
    10497        for (i = 1; argv[i] != NULL; i++) {
    105                 char* pos;
    106                 if ((pos = str_chr(argv[i], '=')) != NULL) {
    107                         argv[i][pos - argv[i]] = '\0';
    108                         set_alias(argv[i], pos + 1);
    109                 }else {
    110                         if(!print_alias(argv[i])) {
     98                char* name = str_dup(argv[i]);
     99                char* value;
     100                if ((value = str_chr(name, '=')) != NULL) {
     101                        name[value - name] = '\0';
     102                        set_alias(name, value + 1);
     103                } else {
     104                        if(!print_alias(name)) {
     105                                free(name);
    111106                                return CMD_FAILURE;
    112107                        }
    113108                }
     109
     110                free(name);
    114111        }
    115112       
Note: See TracChangeset for help on using the changeset viewer.