1
0

shell_startup.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * shell_startup.c
  3. */
  4. #include "private.h"
  5. #include <assert.h>
  6. #include "lub/string.h"
  7. /*----------------------------------------------------------- */
  8. bool_t clish_shell_startup(clish_shell_t *this)
  9. {
  10. const char *banner;
  11. clish_context_t context;
  12. assert(this->startup);
  13. banner = clish_command__get_detail(this->startup);
  14. if (banner)
  15. tinyrl_printf(this->tinyrl, "%s\n", banner);
  16. context.shell = this;
  17. context.cmd = this->startup;
  18. context.pargv = NULL;
  19. return clish_shell_execute(&context, NULL);
  20. }
  21. /*----------------------------------------------------------- */
  22. void clish_shell__set_startup_view(clish_shell_t * this, const char * viewname)
  23. {
  24. clish_view_t *view;
  25. assert(this);
  26. assert(this->startup);
  27. /* Search for the view */
  28. view = clish_shell_find_create_view(this, viewname, NULL);
  29. clish_command__force_view(this->startup, view);
  30. }
  31. /*----------------------------------------------------------- */
  32. void clish_shell__set_startup_viewid(clish_shell_t * this, const char * viewid)
  33. {
  34. assert(this);
  35. assert(this->startup);
  36. clish_command__force_viewid(this->startup, viewid);
  37. }
  38. /*----------------------------------------------------------- */
  39. void clish_shell__set_default_shebang(clish_shell_t * this, const char * shebang)
  40. {
  41. assert(this);
  42. lub_string_free(this->default_shebang);
  43. this->default_shebang = lub_string_dup(shebang);
  44. }
  45. /*----------------------------------------------------------- */
  46. const char * clish_shell__get_default_shebang(const clish_shell_t * this)
  47. {
  48. assert(this);
  49. return this->default_shebang;
  50. }
  51. /*----------------------------------------------------------- */