Changeset 08bd04c in mainline for uspace/app/bdsh/cmds/modules/alias/alias.c
- Timestamp:
- 2018-11-30T05:48:10Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 02c6dcc
- Parents:
- 598e3a7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/alias/alias.c
r598e3a7 r08bd04c 63 63 free(data->value); 64 64 data->value = str_dup(value); 65 66 printf("%s: update value ", cmdname); 67 }else { 65 } else { 68 66 //add new value 69 67 alias_t* data = (alias_t*)calloc(1, sizeof(alias_t)); … … 72 70 73 71 odict_insert(&data->odict, &alias_dict, NULL); 74 75 76 printf("%s: insert value ", cmdname);77 72 } 78 79 printf(alias_format, name, value);80 73 } 81 74 … … 87 80 void help_cmd_alias(unsigned int level) 88 81 { 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); 90 83 return; 91 84 } … … 103 96 size_t i; 104 97 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); 111 106 return CMD_FAILURE; 112 107 } 113 108 } 109 110 free(name); 114 111 } 115 112
Note:
See TracChangeset
for help on using the changeset viewer.