Merge lp:~elementary-apps/pantheon-terminal/fix-1324577-with-cleanup into lp:~elementary-apps/pantheon-terminal/trunk

Proposed by Sergey "Shnatsel" Davidoff
Status: Merged
Approved by: David Gomes
Approved revision: 577
Merged at revision: 577
Proposed branch: lp:~elementary-apps/pantheon-terminal/fix-1324577-with-cleanup
Merge into: lp:~elementary-apps/pantheon-terminal/trunk
Diff against target: 50 lines (+6/-26)
1 file modified
src/TerminalWidget.vala (+6/-26)
To merge this branch: bzr merge lp:~elementary-apps/pantheon-terminal/fix-1324577-with-cleanup
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Alexander Fomin (community) Approve
Review via email: mp+222077@code.launchpad.net

Description of the change

Fix bug #1324577 by dropping the custom argv parser and replacing it with Glib's Shell.parse_argv()
Also drop support for executing shell commands because hardcoding BASH is no longer acceptable.

This work is based on ~xanderfomin's research and https://code.launchpad.net/~xanderfomin/pantheon-terminal/fix-1324577/+merge/221611

To post a comment you must log in.
Revision history for this message
Alexander Fomin (xanderfomin) wrote :

Works OK for me.

review: Approve
Revision history for this message
David Gomes (davidgomes) wrote :

If it works for you then I don't have to test it, I approve the code. Thanks for testing mate.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/TerminalWidget.vala'
2--- src/TerminalWidget.vala 2014-05-19 20:00:57 +0000
3+++ src/TerminalWidget.vala 2014-06-04 16:58:13 +0000
4@@ -251,17 +251,13 @@
5 }
6 }
7
8- public void run_program (string program) {
9- string dir = GLib.Environment.get_current_dir ();
10- string[]? program_with_args = process_argv (program);
11-
12+ public void run_program (string program_string) {
13 try {
14- if (program_with_args != null)
15- this.fork_command_full (Vte.PtyFlags.DEFAULT, dir, program_with_args,
16- null, SpawnFlags.SEARCH_PATH, null, out this.child_pid);
17- else
18- this.fork_command_full (Vte.PtyFlags.DEFAULT, dir, ("bash -c " + program).split (" "),
19- null, SpawnFlags.SEARCH_PATH, null, out this.child_pid);
20+ string[]? program_with_args = null;
21+ Shell.parse_argv (program_string, out program_with_args);
22+
23+ this.fork_command_full (Vte.PtyFlags.DEFAULT, null, program_with_args,
24+ null, SpawnFlags.SEARCH_PATH, null, out this.child_pid);
25 } catch (Error e) {
26 warning (e.message);
27 }
28@@ -393,21 +389,5 @@
29 break;
30 }
31 }
32-
33- private string[]? process_argv (string path) {
34- /* example of the code below.
35- pantheon-terminal -e "sudo apt-get update"
36- tmp[0] == "sudo"
37- tmp[1] == "apt-get update"
38- */
39-
40- string[] tmp = path.split (" ", 2);
41- string? bin_path = GLib.Environment.find_program_in_path (tmp[0]);
42- if (path != null) {
43- return (bin_path + " " + tmp[1]).split (" ");
44- } else {
45- return null;
46- }
47- }
48 }
49 }
50\ No newline at end of file

Subscribers

People subscribed via source and target branches