Bug 488815 - custom servicemenu exec line shell var parameter expansion no longer works
Summary: custom servicemenu exec line shell var parameter expansion no longer works
Status: RESOLVED NOT A BUG
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 24.05.1
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-20 18:59 UTC by Mark Draheim
Modified: 2024-06-22 18:47 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Draheim 2024-06-20 18:59:07 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY

My custom servicemenu .desktop files recently stopped working when their exec line uses shell parameter expansion like ${foo%.*} or even a simple ${foo} while $foo still works. Though  ${foo:-bar} does return the foo value, so I am at a loss at what is happening here.

I tried every way of quoting and escaping I could think of, the parameter expansion either returns empty or the exec line fails with syntax errors.

STEPS TO REPRODUCE
1. create a simple servicemenu .desktop file with Exec=foo="%f"; cp "$foo" "${foo%.*}x".copy
2. place the desktop file in ~/.local/share/kio/servicemenus
3. open a new dolphin window
4. create a file bar.txt
5. point the servicemenu action at it 

OBSERVED RESULT

a file named x.copy is created, meaning the parameter expansion returned empty

EXPECTED RESULT

a file named bar.copy should be created

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.3.0 
Qt Version: 6.7.1

ADDITIONAL INFORMATION

:~> cat .local/share/kio/servicemenus/testpe.desktop
[Desktop Entry]
Encoding=UTF-8
MimeType=all/all
Type=Service
Actions=copyPE
TryExec=cp

[Desktop Action copyPE]
Name=Copy with param expansion
Icon=text
Exec= foo="%f"; cp "$foo" "${foo%.*}x".copy
Comment 1 Mark Draheim 2024-06-22 18:47:54 UTC
alright, seems to be systemd related. Doing the "$$" escaping makes the exec line work again. It might be a good idea to document this prominently because a lot of servicemenu samples on the net will fail