Bug 170867

Summary: konsole -e "command1 && command2" doesn't work as in xterm
Product: [Applications] konsole Reporter: yuri <yuri>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: adaptee, dlaird, kor, robertknight
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description yuri 2008-09-11 18:00:19 UTC
Version:            (using KDE 4.1.1)
OS:                Linux
Installed from:    Ubuntu Packages

There is a problem with 
konsole -e "command1 && command2"


type, for example:
konsole -e "cd src && make"

it doesn't work, but if you run:
xterm -e "cd src && make"

it works perfectly.
Comment 1 Robert Knight 2008-09-11 19:06:03 UTC
When you pass '-e' to Konsole it treats the command afterwards as a program and tries to run it directly.  

Xterm must be starting a new shell and running the command in the shell.  To do this in Konsole run:

konsole -e $SHELL -c "cd src && make"
Comment 2 Robert Knight 2008-09-11 19:08:10 UTC
A useful side-effect of the way Konsole handles '-e' is that if the command does not exist then Konsole displays a helpful warning message in the terminal and starts a shell instead.
Comment 3 yuri 2008-09-15 11:56:05 UTC
it works: many thanks! 

BTW, what is better? 
1- konsole 100% xterm command line compatible
2- don't change it (and put this trick in konsole documentation)
Comment 4 Dave Laird 2009-06-07 19:26:50 UTC
Using konsole -e jed %f from kmail to write/edit e-mail no longer works, regardless of whether you pass the shell environment with -e to it as above or not if you pass the parameter for a file name as Kmail expects. 

konsole -e $SHELL -c "jed" %f works, but it doesn't load the parameter file name from Kmail, hence you get a blank page from Jed. 

Set up kmail and check the box for using an external editor. (jed) 
Start a new message in e-mail and voila! You have Jed open but not the tmp file name used by Kmail. 

My only workaround thus far that seems to be working is "gnome-terminal -x jed %f which works fine.
Comment 5 yuri 2009-06-12 18:02:42 UTC
*** This bug has been confirmed by popular vote. ***
Comment 6 Jekyll Wu 2011-10-13 14:58:01 UTC
(In reply to comment #4)
> Using konsole -e jed %f from kmail to write/edit e-mail no longer works,
> regardless of whether you pass the shell environment with -e to it as above or
> not if you pass the parameter for a file name as Kmail expects. 

The working form is "konsole --nofork -e jed %f". I tested it with konsole-2.7.2 and kmail-4.7.2 . The real problem is currently konsole runs in foreground by default. See bug #262169 for more info.
Comment 7 Jekyll Wu 2011-10-22 12:37:25 UTC
(In reply to comment #3)
> it works: many thanks! 
> 
> BTW, what is better? 
> 1- konsole 100% xterm command line compatible
> 2- don't change it (and put this trick in konsole documentation)

I don't like the xterm way. I don't think parsing and dividing input into commands is something a emulator is expected to do. That is shell's job. AFAIK, xterm is the only emulator bahaving that way.

Putting that into documentation is a good idea.
Comment 8 Jekyll Wu 2011-10-23 06:51:59 UTC
Git commit e586c7ff11c9e7a6f8dc9614e307d165c5ceb35d by Jekyll Wu.
Committed on 23/10/2011 at 08:41.
Pushed by jekyllwu into branch 'master'.

Add explanation on how the -e option works in konsole.

Konsole treats all arguments after the -e option as one commnd
and runs it directly, instead of parsing it and dividing it into
sub-commands for execution. This is different from xterm.

CCBUG:170867

M  +19   -0    doc/manual/index.docbook

http://commits.kde.org/konsole/e586c7ff11c9e7a6f8dc9614e307d165c5ceb35d