swiftbar / SwiftBar

Powerful macOS menu bar customization tool
https://swiftbar.app
MIT License
2.93k stars 92 forks source link

Adds quotes to command parameters with `runInBash` set to false #426

Open fenhl opened 2 weeks ago

fenhl commented 2 weeks ago

Describe the bug When running a command from a plugin that has <swiftbar.runInBash>false</swiftbar.runInBash> configured, and the command has a parameter with a space in it, the command receives that parameter surrounded with single quotes.

To Reproduce Steps to reproduce the behavior:

  1. Copy the command.py file below to ~/Desktop/swiftbar-escape/command.py
  2. Add the test.10s.py file below to your plugin folder, adjusting the username in the path on line 6.
  3. Wait until the “Python Test” plugin appears
  4. Python Test › Run Command
  5. Check ~/Dekstop/swiftbar-escape/python-command.log, it will say ['/Users/<your username>/Desktop/swiftbar-escape/command.py', "'foo bar'"]

Expected behavior python-command.log should say ['/Users/<your username>/Desktop/swiftbar-escape/command.py', 'foo bar'], without the extra quotes

Environment:

Plugin Example:

test.10s.py:

#!/usr/bin/env python3
# <swiftbar.runInBash>false</swiftbar.runInBash>

print('Python Test')
print('---')
print('Run Command | bash=/Users/fenhl/Desktop/swiftbar-escape/command.py param1="foo bar" terminal=false')

command.py:

#!/usr/bin/env python3

import sys

import pathlib

with (pathlib.Path.home() / 'Desktop/swiftbar-escape/python-command.log').open('w') as f:
    print(sys.argv, file=f)

Additional Context: