initviocons/initviocons-0.4.dif

75 lines
2.2 KiB
Plaintext

main.c | 18 +++++++++++++-----
usage.c | 4 +++-
2 files changed, 16 insertions(+), 6 deletions(-)
Index: main.c
===================================================================
--- main.c.orig
+++ main.c
@@ -146,6 +146,7 @@ int main(int argc, char *argv[])
int opt; /* for getopt() */
int should_init = 1; /* shall we do any initialization? */
int output_for_eval = 0; /* print output for eval? */
+ int csh_user = 0; /* the eval oputput belongs to csh */
int fd;
struct stat statbuf;
@@ -161,7 +162,7 @@ int main(int argc, char *argv[])
Quiet = 0;
Igncr = 0;
- while ((opt = getopt(argc, argv, "dqpeF:h")) != -1) {
+ while ((opt = getopt(argc, argv, "dqpeF:ch")) != -1) {
switch (opt) {
case 'd': Debug++; break;
case 'q': Quiet++; break;
@@ -169,6 +170,7 @@ int main(int argc, char *argv[])
case 'e': output_for_eval++; break;
case 'F': sprintf(device, "%s", optarg); break;
case ':': printf("option needs a value\n"); break;
+ case 'c': csh_user++; break;
case 'h': usage(); break;
case '?': usage(); break;
}
@@ -382,10 +384,16 @@ int main(int argc, char *argv[])
/* to be evaled by the shell */
if (output_for_eval) {
- printf ("\nTERM=%s;\n", termstr);
- printf ("COLUMNS=%d;\n", cols);
- printf ("LINES=%d;\n", lines);
- printf ("export COLUMNS LINES;\n");
+ if (csh_user) {
+ printf ("setenv TERM %s;\n", termstr);
+ printf ("setenv COLUMNS %d;\n", cols);
+ printf ("setenv LINES %d\n", lines);
+ } else {
+ printf ("TERM=%s;\n", termstr);
+ printf ("COLUMNS=%d;\n", cols);
+ printf ("LINES=%d;\n", lines);
+ printf ("export COLUMNS LINES\n");
+ }
}
/* FIXME: signal handling */
Index: usage.c
===================================================================
--- usage.c.orig
+++ usage.c
@@ -1,5 +1,6 @@
+#include <stdlib.h>
+#include <stdio.h>
#include "viocons.h"
-#include "stdio.h"
void usage(void)
{
@@ -12,6 +13,7 @@ Usage: " PROGRAM " [-d] [-q] [-p] [-e] [
-e\twrite COLUMNS, LINES and TERM to stdout to be evaled\n\
\t(does not need to imply -q because informational output goes to stderr)\n\
-F\tspecify the terminal device, e.g. /dev/tty1\n\
+-c\toutput C shell code for eval\n\
-h\tshow usage info\n\
\n\
", VERSION);