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

Changeset 7b11315 in mainline


Ignore:
Timestamp:
2021-11-01T21:24:05Z (4 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
24c452b3
Parents:
91ece11b
Message:

Add -c option to terminal to execute a command

This is to allow terminal-mode commands to be run from non-terminal
(i.e. GUI) context. This way is similar to what UN*X style OSses do.
For the record, I think this is a kludge. I think we can do better.
A console/terminal window could be automatically open when needed
(something like that happens in Windows?)

Location:
uspace/app/terminal
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/terminal/main.c

    r91ece11b r7b11315  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4545        printf("Syntax: %s [<options>]\n", NAME);
    4646        printf("\t-d <display-spec> Use the specified display\n");
     47        printf("\t-c <command>      Run command instead of shell\n");
    4748        printf("\t-topleft]         Place window to the top-left corner of "
    4849            "the screen\n");
     
    5253{
    5354        const char *display_spec = UI_DISPLAY_DEFAULT;
     55        const char *command = "/app/bdsh";
    5456        terminal_t *terminal = NULL;
    5557        terminal_flags_t flags = 0;
     
    6870
    6971                        display_spec = argv[i++];
     72                } else if (str_cmp(argv[i], "-c") == 0) {
     73                        ++i;
     74                        if (i >= argc) {
     75                                printf("Argument missing.\n");
     76                                print_syntax();
     77                                return 1;
     78                        }
     79
     80                        command = argv[i++];
    7081                } else if (str_cmp(argv[i], "-topleft") == 0) {
    7182                        ++i;
     
    8394        }
    8495
    85         rc = terminal_create(display_spec, 640, 480, flags, &terminal);
     96        rc = terminal_create(display_spec, 640, 480, flags, command, &terminal);
    8697        if (rc != EOK)
    8798                return 1;
  • uspace/app/terminal/terminal.c

    r91ece11b r7b11315  
    888888
    889889errno_t terminal_create(const char *display_spec, sysarg_t width,
    890     sysarg_t height, terminal_flags_t flags, terminal_t **rterm)
     890    sysarg_t height, terminal_flags_t flags, const char *command,
     891    terminal_t **rterm)
    891892{
    892893        terminal_t *term;
     
    10131014
    10141015        list_append(&term->link, &terms);
    1015         getterm(vc, "/app/bdsh");
     1016        getterm(vc, command);
    10161017
    10171018        term->is_focused = true;
  • uspace/app/terminal/terminal.h

    r91ece11b r7b11315  
    9494
    9595extern errno_t terminal_create(const char *, sysarg_t, sysarg_t,
    96     terminal_flags_t, terminal_t **);
     96    terminal_flags_t, const char *, terminal_t **);
    9797extern void terminal_destroy(terminal_t *);
    9898
Note: See TracChangeset for help on using the changeset viewer.