Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0d0f1a8 in mainline


Ignore:
Timestamp:
2019-06-23T17:30:02Z (16 months ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Branches:
master
Children:
e62f8e3
Parents:
aa3ca1e
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-06-22 16:06:39)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-06-23 17:30:02)
Message:

Unalias prints out warning when an alias could not be found
but proceeds to delete the other given aliases. Also the flag
-a will be treated differentially. In the old version the flag
could have been given with other alias names for deletion. The new
version will now separate those two cases. Either the flag -a is given
or names for deletion are given.

File:
1 edited

Legend:

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

    raa3ca1e r0d0f1a8  
    5858        } else {
    5959                help_cmd_unalias(HELP_SHORT);
    60                 printf("Usage: `%s' [-a] name [name ...]'\n\n"
     60                printf("Usage: `%s' -a'\n"
     61                    "`%s' name [name ...]'\n\n"
    6162                    "If no parameters are given it will display this help message.\n"
    6263                    "If the flag -a is given, all existing aliases will be removed.\n"
    6364                    "If one or multiple parameters are given, then those aliases will be removed.\n",
    64                     cmdname);
     65                    cmdname, cmdname);
    6566        }
    6667}
     
    7576        }
    7677
    77         size_t i;
    7878        odlink_t *alias_link;
    7979
    80         for (i = 1; argv[i] != NULL; i++) {
    81                 if (str_cmp(argv[i], "-a") == 0) {
     80        unsigned int argc = cli_count_args(argv);
     81        if (argc == 2) {
     82                if (str_cmp(argv[1], "-a") == 0) {
    8283                        alias_link = odict_first(&alias_dict);
    8384                        while (alias_link != NULL) {
     
    8990                        return CMD_SUCCESS;
    9091                }
     92        }
    9193
     94        size_t i;
     95        for (i = 1; argv[i] != NULL; i++) {
    9296                alias_link = odict_find_eq(&alias_dict, (void *)argv[i], NULL);
    9397
    9498                if (alias_link == NULL) {
    9599                        cli_error(CL_ENOENT, "%s: No alias '%s' found\n", cmdname, argv[i]);
    96                         return CMD_FAILURE;
     100                } else {
     101                        free_alias(alias_link);
    97102                }
    98 
    99                 free_alias(alias_link);
    100103        }
    101104
Note: See TracChangeset for help on using the changeset viewer.