Skip to content

Commit caeaf6f

Browse files
author
Peter Kosyh
committed
-e option
1 parent 8b5cb1e commit caeaf6f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Options:
6464
* -cpCODEPAGE - Win only (1251 by default), use 65001 for UTF-8;
6565
* -a - autosave on exit and autoload on start (autosave file);
6666
* -x - execute lua script;
67+
* -e - echo input command;
6768
* -m - enable multimedia output;
6869
* -mcmd - enable run cmd on multimedia. Examples: -m/usr/bin/xdg-open (Linux), -m/bin/plumb (Plan9), -m"start\"\"" (Windows).
6970

main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ extern char *dirname(char *);
4242

4343
static int opt_log = 0;
4444
static int opt_lua = 0;
45+
static int opt_echo = 0;
4546
static int opt_debug = 0;
4647
static int opt_width = WIDTH;
4748
static char *opt_autoload = NULL;
@@ -314,6 +315,8 @@ int main(int argc, const char **argv)
314315
} else if (!strncmp(argv[i], "-m", 2)) {
315316
opt_mmedia = 1;
316317
mmedia_bin = argv[i] + 2;
318+
} else if (!strcmp(argv[i], "-e")) {
319+
opt_echo = 1;
317320
} else if (!strncmp(argv[i], "-d", 2)) {
318321
opt_debug = 1;
319322
reopen_stderr(argv[i] + 2);
@@ -377,7 +380,8 @@ int main(int argc, const char **argv)
377380
mmedia(0); mmedia(1);
378381
if (opt_autoload) {
379382
snprintf(cmd, sizeof(cmd), "load %s", opt_autoload);
380-
printf("%s\n", cmd);
383+
if (opt_echo)
384+
printf("%s\n", cmd);
381385
str = instead_cmd(cmd, &rc);
382386
} else
383387
str = instead_cmd("look", &rc);
@@ -400,6 +404,8 @@ int main(int argc, const char **argv)
400404
printf("\n");
401405
break;
402406
}
407+
if (opt_echo)
408+
fprintf(stdout, "%s\n", p);
403409
rc = 1; str = NULL;
404410

405411
if (*p == '/') {

0 commit comments

Comments
 (0)