Bug 178244 - Incorrect use of && and || in Commandline while trying to detect existing firefox instance
Summary: Incorrect use of && and || in Commandline while trying to detect existing fir...
Status: RESOLVED DUPLICATE of bug 134671
Alias: None
Product: klipper
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Esben Mose Hansen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-20 01:52 UTC by Paul Fee
Modified: 2009-02-14 15:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Remove detection of existing firefox instance as firefox does this itself (905 bytes, patch)
2008-12-21 00:44 UTC, Paul Fee
Details

Note You need to log in before you can comment on or make changes to this bug.
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 ***