software-jessies-org / jessies

Terminator, Evergreen, lwm and friends
GNU General Public License v2.0
84 stars 19 forks source link

org.jessies.terminator -e does not appear to work #31

Closed LadyAleena closed 5 years ago

LadyAleena commented 5 years ago

While in Geany, one can execute programs in a terminal. This is from the command <term> -e "/bin/sh %c". When I put org.jessies.terminatgor -e "/bin/sh %c" in as the terminal emulator to use, I get an error telling me that it cannot execute build command. xterm, uxterm, konsole, and xfce4-terminal all work for this; and I would love it in org.jessies.terminator would also work for this.

martindorey commented 5 years ago

"cannot execute build command" doesn't seem like a Terminator error.

https://github.com/software-jessies-org/jessies/blob/1b7dd78a9aac8d383c04ce9987b33912723cc5cc/terminator/src/terminator/TerminatorOpener.java#L21

... agrees with your -e and the man page alleges its treatment is compatible with xterm but, while the package is called org.jessies.terminator, the script it installs is called just terminator, unless you've done something fancy with eg dpkg-divert.

On Fri, Jul 19, 2019 at 22:37 LadyAleena notifications@github.com wrote:

While in Geany, one can execute programs in a terminal. This is from the command -e "/bin/sh %c". When I put org.jessies.terminatgor -e "/bin/sh %c" in as the terminal emulator to use, I get an error telling me that it cannot execute build command. xterm, uxterm, konsole, and xfce4-terminal all work for this; and I would love it in org.jessies.terminator would also work for this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/software-jessies-org/jessies/issues/31?email_source=notifications&email_token=AEBT5GRG4POPWWMF2VMFCW3QAKQB3A5CNFSM4IFNUBUKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HANL2ZA, or mute the thread https://github.com/notifications/unsubscribe-auth/AEBT5GXPU2JVGAPK3DEB6FLQAKQB3ANCNFSM4IFNUBUA .

LadyAleena commented 5 years ago

I put terminator -e "/bin/sh %c" in as the terminal emulator in Geany, and it still will not execute the script. When I go to run the script, the following is returned:

Can't execute "/bin/sh /tmp/geany_run_script_ZZYE5Z.sh": (No such file or directory)

When I go to the directory and run the file, the file then works.

As I said in my original post, xterm, uxterm, konsole, and xfce4-terminal all work for this. It would be nice if terminator would too.

martindorey commented 5 years ago

While I said the Syntax I linked to agreed with the -e, that was a little disingenuous of me, as it didn't agree with the quotes. Inappropriate quotes would explain the error message I guess you helpfully added with your edit above, but which github, rather poorly, didn't mail me. So much for our claim in the man page of xterm compatibility, though perhaps xterm supports either. I don't have access to a Real Computer at the moment to try this on.

enh commented 5 years ago

yeah, terminator -e /bin/sh %c works for me (testing with Geany), but you're right --- xterm seems to magically accept either one argument with the whole command or the one-argument-per-argument style in the documentation.

yeah, looking at the xterm source, if the regular exec fails because you put everything into one argument, it tries to sh -c that argument:

>->-TRACE_ARGV("spawning command", command_to_exec);
>->-execvp(*command_to_exec, command_to_exec);
>->-if (command_to_exec[1] == 0)
>->-    execlp(shell_path, shname, "-c", command_to_exec[0],
>->->-   (void *) 0);

that's pretty gross, but the submitter seems to be correct that other terminal emulators have copied this.

here's a patch that works for me, which i'll submit shortly...

--- a/terminator/native/all/pty/PtyGenerator.h
+++ b/terminator/native/all/pty/PtyGenerator.h
@@ -216,6 +216,17 @@ private:
         signal(SIGCHLD, SIG_DFL);

         execvp(executable.c_str(), argv);
+        // XTerm (and just about everything else) tries again if the initial
+        // exec fails and there was only a single argument, in case the user
+        // accidentally munged all their arguments into one argument.
+        // This seems deeply unfortunate, but it does make Geany work out of th
e
+        // box (see https://github.com/software-jessies-org/jessies/issues/31),
+        // and other terminal emulators do this too.
+        if (argv[1] == nullptr) {
+            const char* shell = getenv("SHELL");
+            if (shell == nullptr) shell = "/bin/sh";
+            execlp(shell, shell, "-c", argv[0], nullptr);
+        }
         throw unix_exception("Can't execute \"" + executable + "\"");
     }

as i say in the code comment, this fixes Geany out of the box (via x-terminal-emulator) for me.

martindorey commented 5 years ago

That seems likely to have broken my nightly build. I note the i386. I probably use some hideously downrev chroot to compile that. We no longer do that for work stuff, so I can probably easily modernize the build environment to brush this away, but it'll be a few hours at least.

/home/martind/jessies/nightlies/terminator/.generated/native/all/pty/i386_Linux/PtyGenerator.h:225:9: error: identifier ‘nullptr’ is a keyword in C++11 [-Werror=c++0x-compat] if (argv[1] == nullptr) { ^

martindorey commented 5 years ago

I'd misdiagnosed that but it's fixed now and I've uploaded builds with Elliott's fix.