Bug 102941 - User created sessions with "~" (like "~/somescript") in execute field or error in command doesn't appear in menu
Summary: User created sessions with "~" (like "~/somescript") in execute field or erro...
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-31 16:23 UTC by Dmitriy Ulupov
Modified: 2005-04-01 18:53 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitriy Ulupov 2005-03-31 16:23:51 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    Compiled From Sources
Compiler:          gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) 
OS:                Linux

Starting Konsole.
Opening Settings -> Configure Konsole.

Go to "Session" tab.

Enter any Name.
Fill "Execute" field like that:

~/tools/open_ssh_to_smth

OR

any_error_command

Click on Save Session.
Click Ok.

Close Konsole.
Open it.

And your new session silently ignored.
It doesn't appear in "Session" menu.

I thing there are two problems.

1) Konsole can't understand "~" in execute field.
2) Konsole silently ignores errors in "Execute" field.

There must be some check about "execute" field contents.
Comment 1 Dmitriy Ulupov 2005-03-31 16:40:05 UTC
And some more.

If I save new session with name "123", with "~/tools/connect" in execute field and start Konsole with a command:

konsole --type 123

... everything works! It opens new session 123 and executes ~/tools/connect
Comment 2 Kurt Hindenburg 2005-04-01 00:59:14 UTC
Yes and yes... thanks for the info.
Comment 3 Kurt Hindenburg 2005-04-01 03:56:48 UTC
This has been fixed...

Replace ~ with homeDirPath in Session's Exec entries.

BUG: 102941


  M +1 -1      konsole.cpp   1.526


--- kdebase/konsole/konsole/konsole.cpp  #1.525:1.526
@@ -3069,4 +3068,5 @@ void Konsole::addSessionCommand(const QS
   }
 
+  exec = exec.replace( "~", QDir::homeDirPath() );
   exec = KRun::binaryName(exec, false);
   QString pexec = KGlobal::dirs()->findExe(exec);
Comment 4 Thiago Macieira 2005-04-01 04:05:32 UTC
Hmm... that doesn't look right.

~ alone is $HOME
but ~thiago should point to thiago's HOME. In other words:

$ echo ~
/home/thiago
$ echo ~thiago
/home/thiago

but:
$ echo \~ | sed "s,~,$HOME,"
/home/thiago
$ echo \~thiago | sed "s,~,$HOME,"
/home/thiagothiago
Comment 5 Kurt Hindenburg 2005-04-01 06:43:57 UTC
Well, something is wrong with using BUGS: and CCMAIL in CVS commits tonight:

CVS commit by hindenburg: 

Try this again... expand ~ in Exec=~/script
Qt/KDE needs a function for this.

CCBUGS: 102941


  M +13 -2     konsole.cpp   1.527


--- kdebase/konsole/konsole/konsole.cpp  #1.526:1.527
@@ -3068,7 +3068,18 @@ void Konsole::addSessionCommand(const QS
   }
 
-  exec = exec.replace( "~", QDir::homeDirPath() );
   exec = KRun::binaryName(exec, false);
+
+  if ( exec.startsWith( "~/" ) ) {        // ~/script
+    exec = exec.remove( 0, 1 );      // ~
+    exec = exec.prepend( QDir::homeDirPath() );
+  } else if ( exec.startsWith( "~" ) ) {  // ~user/script
+      // FIXME: What do when ~user != ~ ?
+      // We could check that user == current user... blah!
+    kdWarning()<<"Unable to handle Exec=~user/ (use ~/ or full path): "<<exec<<" in "<<path.latin1()<<endl;
+    return;    // ignore
+  }
+
   QString pexec = KGlobal::dirs()->findExe(exec);
+
   if (typ.isEmpty() || txt.isEmpty() || typ != "KonsoleApplication"
       || ( !exec.isEmpty() && pexec.isEmpty() ) )
@@ -3076,6 +3087,6 @@ void Konsole::addSessionCommand(const QS
     if (!path.isEmpty())
        delete co;
+    kdWarning()<<"Unable to use "<<path.latin1()<<endl;
     return; // ignore
-
   }
Comment 6 Dirk Mueller 2005-04-01 12:08:49 UTC
test - ignore
Comment 7 Kurt Hindenburg 2005-04-01 18:53:18 UTC
CVS commit by hindenburg: 

Use KShell::tildeExpand (thanks ossi).

CCBUGS: 102941


  M +2 -11     konsole.cpp   1.528


--- kdebase/konsole/konsole/konsole.cpp  #1.527:1.528
@@ -109,4 +109,5 @@ Time to start a requirement list.
 
 #include <kaction.h>
+#include <kshell.h>
 #include <qlabel.h>
 #include <kpopupmenu.h>
@@ -3069,15 +3070,5 @@ void Konsole::addSessionCommand(const QS
 
   exec = KRun::binaryName(exec, false);
-
-  if ( exec.startsWith( "~/" ) ) {        // ~/script
-    exec = exec.remove( 0, 1 );      // ~
-    exec = exec.prepend( QDir::homeDirPath() );
-  } else if ( exec.startsWith( "~" ) ) {  // ~user/script
-      // FIXME: What do when ~user != ~ ?
-      // We could check that user == current user... blah!
-    kdWarning()<<"Unable to handle Exec=~user/ (use ~/ or full path): "<<exec<<" in "<<path.latin1()<<endl;
-    return;    // ignore
-  }
-
+  exec = KShell::tildeExpand(exec);
   QString pexec = KGlobal::dirs()->findExe(exec);