#include <string.h>
#include <fcntl.h>
-#ifdef BASH_BUILTIN
-#include "bash/config.h"
-#include "bash/shell.h"
-#include "bash/builtins.h"
-#include "bash/builtins/common.h"
-#include "bash/builtins/bashgetopt.h"
-#endif
-
-#ifdef BASH_BUILTIN
-int xtitle_builtin(WORD_LIST *list)
-#else
int main(int argc, char *argv[])
-#endif
{
int query = 0;
int fd;
int openned = 0;
+ int i;
+ int hunoz;
-#ifdef BASH_BUILTIN
- reset_internal_getopt();
-#endif
for (;;) {
-#ifdef BASH_BUILTIN
- int i;
- i = internal_getopt(list, "q");
-#else
- int i = getopt(argc, argv, "q");
-#endif
+ i = getopt(argc, argv, "q");
if (i < 0)
break;
switch (i) {
query = 1;
break;
default:
-#ifdef BASH_BUILTIN
- builtin_usage();
-#else
- fprintf(stderr, "usage: xtitle [-q] [string]\n");
-#endif
+ fprintf(stderr, "usage: xtitle [-q] [STRING]\n");
return (1);
}
}
-#ifdef BASH_BUILTIN
- if (!query && loptend == 0) {
-#else
if (!query && optind == argc) {
-#endif
fprintf(stderr, "xtitle: no string to set\n");
return (1);
}
}
if (!query) {
-#ifdef BASH_BUILTIN
- WORD_LIST *l = loptend;
- char sp = ' ';
- write(fd, "\33]0;", 4);
- while (l) {
- write(fd, l->word->word, strlen(l->word->word));
- if (l->next)
- write(fd, &sp, 1);
- l = l->next;
- }
- write(fd, "\7", 2);
-#else
- int i;
char sp = ' ';
- write(fd, "\33]0;", 4);
+ hunoz = write(fd, "\33]0;", 4);
for (i = optind; i < argc; i++) {
- write(fd, argv[i], strlen(argv[i]));
+ hunoz = write(fd, argv[i], strlen(argv[i]));
if (i < argc - 1)
- write(fd, &sp, 1);
+ hunoz = write(fd, &sp, 1);
}
- write(fd, "\7", 2);
-#endif
+ hunoz = write(fd, "\7", 2);
} else {
struct termios o, n;
char hack;
n.c_cflag &= ~(CSIZE|PARENB);
n.c_cflag |= CS8;
tcsetattr(fd, TCSAFLUSH, &n);
- write(fd, "\33[21t", 5);
+ hunoz = write(fd, "\33[21t", 5);
while (state != -1) {
if (read(fd, &hack, 1) < 1)
return (0);
}
-
-
-#ifdef BASH_BUILTIN
-
-static char *xtitle_doc[] = {
- "Either set or read the title of the current xterm window. With the",
- "-q option, writes the current xterm title to standard output. Without",
- "the -q option, sets the xterm title to be the arguments given,",
- "separated by space characters. [By Mark Wooding, mdw@nsict.org]",
- 0
-};
-
-struct builtin xtitle_struct = {
- "xtitle",
- xtitle_builtin,
- BUILTIN_ENABLED,
- xtitle_doc,
- "xtitle [-q] [arguments]",
- 0
-};
-
-#endif