hluk / CopyQ

Clipboard manager with advanced features
GNU General Public License v3.0
8.63k stars 440 forks source link

executed commands run twice? #2306

Closed joedefen closed 1 year ago

joedefen commented 1 year ago

Describe the bug When a string starting with "ExEc=" is copied to the keyboard, I wish that whole text be run once as a bash command, but it being run twice. Probably, it is a pilot error, but I don't see any controls to fix this.

To Reproduce

  1. In "+ Add" command..
  2. Choose "Automatic"
  3. Enter Name: Run ExEc2
  4. Advanced: Content: ^ExEc=
  5. Advanced: Format: text/plain
  6. Command: copyq: execute('bash', null, input())
  7. Click: Apply

Expected behavior When I copy something to the keyboard, e.g., "ExEc= mpv movie.mp4", I expect mpv to be run once, but it is launched twice.

Screenshots If applicable, add screenshots to help explain your problem.

Version, OS and Environment CopyQ Clipboard Manager 6.0.1 Qt: 5.15.2 KNotifications: 5.89.0 Compiler: GCC Arch: x86_64-little_endian-lp64 OS: KDE neon 5.27

Additional context I'm stumped.

joedefen commented 1 year ago

OK, so I unchecked "Run automatic commands on selection" and that seems to have fixed the matter. Now, I'm not sure why that has effect, because there is no "selection" involved here. A click on a personal web page does the copy to the clipboard. But, it is now working for me. Whatever.

hluk commented 1 year ago

Yup, automatic commands run on both selection and clipboard by default. This can be distinguished in the commands using isClipboard() function.

copyq:
if (!isClipboard()) {
    abort();
}
...