Guest User

Untitled

a guest
Apr 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1. diff --git a/src/builtins/alias.c b/src/builtins/alias.c
  2. index f648006..d880592 100644
  3. --- a/src/builtins/alias.c
  4. +++ b/src/builtins/alias.c
  5. @@ -89,4 +89,27 @@ int alias_builtin(int argc, char **args)
  6.         return 0;
  7.  }
  8.  
  9. +void find_alias(expr *e)
  10. +{
  11. +       if (aliases == NULL)
  12. +               aliases = new_hash_table();
  13. +
  14. +       expr *ex;
  15. +       char **new_args;
  16. +       int i = 0;
  17. +
  18. +       ex = find_hash_key(aliases, e->args[0]);
  19. +
  20. +       if (ex) {
  21. +               new_args = new_args_list();
  22. +
  23. +               while (ex->args[i]) {
  24. +                       add_arg(new_args, strdup(ex->args[i]));
  25. +                       i++;
  26. +               }
  27. +
  28. +               e->args = new_args;
  29. +       }
  30. +}
  31. +
  32.  #endif /* __alias_c */
  33. \ No newline at end of file
  34. diff --git a/src/eval.c b/src/eval.c
  35. index ada05d4..8e8c4b0 100644
  36. --- a/src/eval.c
  37. +++ b/src/eval.c
  38. @@ -102,6 +102,8 @@ int eval_expr(expr *e)
  39.         pid_t pid;
  40.  
  41.         if (e->type == SIMPLE) {
  42. +               find_alias(e);
  43. +
  44.                 /* That's a dirty hack !! */
  45.                 builtin = find_builtin(e->args[0]);
  46.                 if (builtin) {
Add Comment
Please, Sign In to add comment