[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sensible-x-terminal and x-terminal-emulator



On Fri, Jul 21, 2000 at 06:19:21PM +0900, Tomohiro KUBOTA wrote:
> From: Anthony Towns <aj@azure.humbug.org.au>
> > Would it help if I sponsored the package and uploaded for you?
> Great!  I am happy to hear that.  Please!

Okay, I'll just have a couple more goes at convincing you to divert xterm
first... :) 

> > If so, just a couple of questions. I was under the impression that
> > one of the main problems with the existing situation was that programs
> > just defaulted to calling xterm, which doesn't work because xterm isn't
> > perfect. This package doesn't seem to fix that at all: programs still
> At first, my goal is that sensible-x-terminal-emulator will be
> written in Debian Policy

Well, there'll be a couple of problems with this. One is that the policy
for sensible-xtermemu will be different to the existing policy for
sensible-editor and sensible-pager: those programs are meant to *not*
be called, direct support for $EDITOR and $PAGER is what's required,
and sensible-{editor,pager} is just a fallback.

> and be integrated into 'debianutils'

xfree86-common would make more sense, I suspect.

> For example, if sensible-x-terminal-emulator diverts xterm,
> sensible-x-terminal-emulator may call x-terminal-emulator and
> it may be a link to xterm.  It makes an infinite loop.

Yes. The way sensible-{editor,pager} avoid this is by making those
programs so completely boring they're not worth pointing an alternative
link at them. sensible-xtermemu is somewhat more interesting: it'll
select the "right" xtermemu based on LANG as well as choosing one you
select explicitly, or falling back.

It's probably not too difficult to avoid the infinite loop,
though. Umm. Hmm.  Attached. If you just use the check() function within
exec2(), you should be able to avoid any accidental infinite loops.

> I understand it is the easiest and quickest way to divert xterm,
> since xterm is the de-facto standard of X terminal emulators and 
> many softwares calls xterm via hard-coding.  And more, in the early 
> stage of developement of sensible-x-terminal-emulator, I had better 
> divert xterm to appeal many users.  However, it may confuse many 
> users who wanted to invoke the very xterm and who don't know about 
> sensible-x-terminal-emulator mechanism.

Well, it's fairly trivial to have it do this anyway: as long as one of
your fallbacks is "xterm.x11" and you don't accidently infinite loop,
you're fine.

I'm not really saying that you want to leave it this way when you make
the policy proposal, just that this will be a good way to flush out
any problems in the meantime. If things fail with xterm diverted to
sensible-xtermemu, then they'll need to be rewritten to cope with either
xterms anyway.

> > Until Debian Policy is modified, you can use this package as following:
> > (1) copy example files of configuration
> >     (/usr/share/doc/sensible-xtermemu/examples/*) into
> >     /etc/X11/sensible-x-terminal-emulator/*.
> > (2) rewrite some programs or configuration file which calls X terminal
> >     emulator to call /usr/bin/sensible-x-terminal-emulator.  For
> >     example, /etc/menu-methods/menu.h has 'xterm'.

With xterm diverted, you don't really have to do either of these. This
seems like a win.

Cheers,
aj

-- 
Anthony Towns <aj@humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. GPG signed mail preferred.

  ``We reject: kings, presidents, and voting.
                 We believe in: rough consensus and working code.''
                                      -- Dave Clark
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

int check(char *self, char *exe) {
	char *path = getenv("PATH");
	struct stat statexe;
	struct stat statself;
	char *pathname;
	char *pch;
	int found = 0;

	stat(self, &statself);

	pathname = malloc(strlen(exe) + strlen(path) + 2);
	if (strchr(exe, '/') == NULL) {
		for (; path; path = strchr(path, ':')) {
			if (path[0] == ':') path++;
			if (path[0] == ':' || path[0] == '\0') {
				path = ".";
			}
			strcpy(pathname, path);
			pch = strchr(pathname, ':');
			if (pch) *pch = '\0';
			strcat(pathname, "/");
			strcat(pathname, exe);
			if (stat(pathname, &statexe) == 0) {
				found = 1;
				break;
			}
		}
	} else {
		if (stat(exe, &statexe) == 0) {
			found = 1;
		}
	}

	if (!found) return -1;
	if (statself.st_dev == statexe.st_dev 
		&& statself.st_ino == statexe.st_ino) 
	{
		return 1;
	}

	return 0;
}

int main(int argc, char **argv) {
	int i;

	for (i = 1; i < argc; i++) {
		printf("Checking \"%s\"...", argv[i]);
		switch(check(argv[0], argv[i])) {
		  case -1: printf("not found\n"); break;
		  case  0: printf("different\n"); break;
		  case  1: printf("self\n"); break;
		}
	}

	return 0;
}

Attachment: pgptOBwx2haZC.pgp
Description: PGP signature


Reply to: