mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Added two simple command-line arguments: -fn (so I can have my Font
Of Choice back :-) and -e to run a command other than $SHELL. [originally from svn r2037]
This commit is contained in:
parent
0dff7f90da
commit
bacc5cf102
25
unix/pterm.c
25
unix/pterm.c
@ -1111,11 +1111,36 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
extern int pty_master_fd; /* declared in pty.c */
|
extern int pty_master_fd; /* declared in pty.c */
|
||||||
|
extern char **pty_argv; /* declared in pty.c */
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
do_defaults(NULL, &cfg);
|
do_defaults(NULL, &cfg);
|
||||||
|
|
||||||
|
while (--argc > 0) {
|
||||||
|
char *p = *++argv;
|
||||||
|
if (!strcmp(p, "-fn")) {
|
||||||
|
if (--argc > 0) {
|
||||||
|
strncpy(cfg.font, *++argv, sizeof(cfg.font));
|
||||||
|
cfg.font[sizeof(cfg.font)-1] = '\0';
|
||||||
|
} else
|
||||||
|
err = 1, fprintf(stderr, "pterm: -fn expects an argument\n");
|
||||||
|
}
|
||||||
|
if (!strcmp(p, "-e")) {
|
||||||
|
if (--argc > 0) {
|
||||||
|
int i;
|
||||||
|
pty_argv = smalloc((argc+1) * sizeof(char *));
|
||||||
|
++argv;
|
||||||
|
for (i = 0; i < argc; i++)
|
||||||
|
pty_argv[i] = argv[i];
|
||||||
|
pty_argv[argc] = NULL;
|
||||||
|
break; /* finished command-line processing */
|
||||||
|
} else
|
||||||
|
err = 1, fprintf(stderr, "pterm: -e expects an argument\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inst->fonts[0] = gdk_font_load(cfg.font);
|
inst->fonts[0] = gdk_font_load(cfg.font);
|
||||||
inst->fonts[1] = NULL; /* FIXME: what about bold font? */
|
inst->fonts[1] = NULL; /* FIXME: what about bold font? */
|
||||||
inst->font_width = gdk_char_width(inst->fonts[0], ' ');
|
inst->font_width = gdk_char_width(inst->fonts[0], ' ');
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pty_master_fd;
|
int pty_master_fd;
|
||||||
|
char **pty_argv;
|
||||||
|
|
||||||
static void pty_size(void);
|
static void pty_size(void);
|
||||||
|
|
||||||
@ -87,11 +88,14 @@ static char *pty_init(char *host, int port, char **realhost, int nodelay)
|
|||||||
dup2(slavefd, 2);
|
dup2(slavefd, 2);
|
||||||
setsid();
|
setsid();
|
||||||
setpgrp();
|
setpgrp();
|
||||||
tcsetpgrp(0, getpgrp());
|
tcsetpgrp(slavefd, getpgrp());
|
||||||
/* Close everything _else_, for tidiness. */
|
/* Close everything _else_, for tidiness. */
|
||||||
for (i = 3; i < 1024; i++)
|
for (i = 3; i < 1024; i++)
|
||||||
close(i);
|
close(i);
|
||||||
execl(getenv("SHELL"), getenv("SHELL"), NULL);
|
if (pty_argv)
|
||||||
|
execvp(pty_argv[0], pty_argv);
|
||||||
|
else
|
||||||
|
execl(getenv("SHELL"), getenv("SHELL"), NULL);
|
||||||
/*
|
/*
|
||||||
* If we're here, exec has gone badly foom.
|
* If we're here, exec has gone badly foom.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user