Bug 178244

Summary: Incorrect use of && and || in Commandline while trying to detect existing firefox instance
Product: [Applications] klipper Reporter: Paul Fee <paul.f.fee>
Component: generalAssignee: Esben Mose Hansen <kde>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Remove detection of existing firefox instance as firefox does this itself

Description Paul Fee 2008-12-20 01:52:59 UTC
Version:           v0.9.7 (using Devel)
OS:                Linux
Installed from:    Compiled sources

Klipper by default includes a selection of Actions.  Matching regular expresses can present a popup with a list of commands to run.

These are visible in SVN:
http://websvn.kde.org/trunk/KDE/kdebase/workspace/klipper/klipperrc.desktop?revision=896751&view=markup

The commandline statements for invoking Mozilla and Firefox look suspicious, e.g.

Commandline=ps x |grep -q '[f]irefox' && firefox -remote openURL(%s, new-window) || firefox %s

I presume the intent here is to invoke the first command (firefox -remote) is the ps picks up an existing firefox instance.  If none is detected, then invoke a new instance of firefox.

However the || operator will act on the exit code of the "firefox -remote" command, not the exit status of "ps x | grep -q '[f]irefox".

This can be confirmed using the "true" and "false" utilities.

$ true && echo first
first
$ true && false || echo second
second

The first test shows that && behaves as expected.  The second shows that the || operates on the immediately preceeding command.

These subtleties can be easily avoided as firefox now reuses windows by default.  Firefox (tested on 3.0.5) handles detection of existing processes, therefore we can simplify the klipper Commandline and avoid using ps to detect an existing instance.

http://osdir.com/ml/kde.akregator.user/2005-12/msg00010.html

Mozilla (tested on seamonkey 1.1.12) also reuses existing instances.

I'd suggest the Commandlines for firefox and mozilla be changed to:
firefox %s
mozilla %s

This may help with bug 165726
https://bugs.kde.org/show_bug.cgi?id=165726
Comment 1 Paul Fee 2008-12-21 00:44:02 UTC
Created attachment 29502 [details]
Remove detection of existing firefox instance as firefox does this itself

By avoiding use of || and && we avoid unwanted side-effects such as inadvertently running firefox twice after selecting an action's command from klipper.
Comment 2 Tommi Tervo 2009-02-14 15:17:46 UTC

*** This bug has been marked as a duplicate of bug 134671 ***