void parseRemoveAlias(Node ** head, char * string){ char tempS[1000]; char * aliasTemp = NULL; char ** aliasArgs = NULL; #if TESTER printf("input string %s<---\n", string); #endif strcpy(tempS,string); aliasTemp = strtok(tempS , "="); #if TESTER printf("---->DEBUG:alias temp =%s<-------\n", aliasTemp); #endif //We want to remove the alias word makeargs(aliasTemp, &aliasArgs); //copy back the alias word strcpy(aliasTemp, aliasArgs[1]); //clean the memory a bit clean(2, aliasArgs); #if TESTER printf("---->DEBUG:alias temp =%s<-------\n", aliasTemp); #endif removeAlias(head, aliasTemp); }
int addAlias(struct confModules *cf, char *alias, char *aliasdef, int flags) { int x; char *tmp; if (flags & CM_REPLACE || flags & CM_COMMENT) removeAlias(cf,alias,flags); x=strlen(alias)+strlen(aliasdef)+10; tmp = malloc(x); snprintf(tmp,x,"alias %s %s",alias,aliasdef); addLine(cf,tmp,flags); return 0; }
// This function execute builtin functions void do_it(int bi) { switch(comtab[bi].builtin) { case BYE: goodbye = 1; // Set global goodbye variable to true break; case CDHOME: goHome(); break; case CD: // Go to specified path gotoDir(bi); break; case SETALIAS: // Adding alias to the alias table printf("adding alias to table\n"); createAlias(comtab[curr_cmd].atptr->args[0], comtab[curr_cmd].atptr->args[1]); printf("Done adding alias to table\n"); break; case UNALIAS: removeAlias(comtab[curr_cmd].atptr->args[0]); break; case PRINTALIAS: // Print either a specific alias or all aliases if( comtab[curr_cmd].nargs == 0) { printf("calling\n"); listAliases(); // Print all aliases } else { printAnAlias(comtab[curr_cmd].atptr->args[0]); // Print specific alias } break; case SETENV: // Set environment if( putenv( strcat(strcat(comtab[curr_cmd].atptr->args[0],"="),comtab[curr_cmd].atptr->args[1]) ) != 0) { printf("%s\n", strerror(errno)); } break; case UNSETENV: // Removing environment variables if( unsetenv(comtab[bi].atptr->args[0]) == -1) { printf("%s\n", strerror(errno)); } break; case PRINTENV: // Print environment variables printallEnv(); break; } }
void unalias(char* name) { removeAlias(name); }