Comment 1 for bug 348174

Revision history for this message
Chow Loong Jin (hyperair) wrote : Re: [Bug 348174] [NEW] geany creates and leaves around copies of geany_run_script.sh

On Tue, 2009-03-24 at 21:50 +0000, martin wrote:
> Public bug reported:
>
> repro steps:
> 1. geany a.py
> 2. press F5 to run it
> 3. it shows a terminal with some error and asks user to press ENTER to close the terminal
> 4. instead press CTRL-C
>
> Actual:
> geany how aborts geany_run_script.sh execution so that the last line nevers gets run (the last line is "rm $0" because the user is never supposed to even know that geany_run_script.sh is being created, it's an implementation detail).
>
> Expected:
> geany should never leave copies of geany_run_script.sh around
>
>
> Note #1: I use geany for tons of stuff.... I did a quick search in my home dir and found tens of copies littered all over, in all kinds of dirs. they are just junk, I don't want them there.
>
> Good news is that the fix is easy, the "rm $0" command just needs to
> execute before the terminal window waits for the ENTER key stroke.
>
> The following patch does exactly that:
>
> diff -r -u geany_apt_clean/geany-0.16/src/build.c geany_apt/geany-0.16/src/build.c
> --- geany_apt_clean/geany-0.16/src/build.c 2009-02-10 22:10:50.000000000 +0100
> +++ geany_apt/geany-0.16/src/build.c 2009-03-24 22:41:19.000000000 +0100
> @@ -944,7 +944,7 @@
> #else
> str = g_strdup_printf(
> "#!/bin/sh\n\n%s\n\necho \"\n\n------------------\n(program exited with code: $?)\" \
> - \n\n%s\nrm $0\n", cmd, (autoclose) ? "" :
> + \nrm $0\n%s\n", cmd, (autoclose) ? "" :
> "\necho \"Press return to continue\"\n#to be more compatible with shells like dash\ndummy_var=\"\"\nread dummy_var");
> #endif
>
> ** Affects: geany
> Importance: Unknown
> Status: Unknown
>
> ** Affects: geany (Ubuntu)
> Importance: Undecided
> Status: New
>
> ** Bug watch added: SourceForge.net Tracker #2710482
> http://sourceforge.net/support/tracker.php?aid=2710482
>
> ** Also affects: geany via
> http://sourceforge.net/support/tracker.php?aid=2710482
> Importance: Unknown
> Status: Unknown
>
Your fix will still fail if the program goes into an infinite loop and
you terminate it. How about putting rm $0 at the beginning of the
script? Somewhere just after #!/bin/sh\n, but before %s.
--
Chow Loong Jin