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

Changeset 7b11315 in mainline for uspace/app/terminal/main.c


Ignore:
Timestamp:
2021-11-01T21:24:05Z (3 months 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?)

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.