support $(command) substitution in labels#10
support $(command) substitution in labels#10dylanmtaylor wants to merge 2 commits intoStorageB:mainfrom
Conversation
|
Example above shows hostname and uname -r output in the menu. Note that this does technically allow arbitrary code execution every time the menu is opened. Commands entered into menu entries should be chosen carefully. |
|
Dylan sent the PR before I could file the issue! We'd love to ship this as the menu in projectbluefin.io - but thought it'd be awesome to have the user's hostname in there subtly. Right now we'd have to ship a custom service unit to update the hostname so we'd figure we'd pitch the idea directly since there's probably nice clever things people can put in there. Thanks for your consideration! |
|
This is a great idea, and I'd be happy to incorporate it into this extension and thrilled to see it shipped with Bluefin! Thank you for the pull request and code. After a quick review and some testing, I have a few thoughts. I think there needs to be some safeguards to prevent the user from entering something that would break their system.
Let me know your thoughts! |
This is a very good point. Let me try to make it timeout after ~1 second. This really should be things that come back nearly immediately. I did say "Commands entered into menu entries should be chosen carefully" ;) |
|
By prefixing the command with timeout 1, the timeout utility (from coreutils, so we can assume it's on all Linux distros) will kill the child process after 1 second. |
|
Great, I'll give a try when I'm at my computer.
Haha very true. I try to never underestimate the user's "creativity" though. And yes, ping was a comical example, but I can see someone trying to pull data from a webpage or server, or technically you could even run a custom script from there... I would agree that's not the intent for this, but I wouldn't want a user thinking your menu is broken (if they try something creative). An alternative to a 1 second timeout would be use Your call on how to handle it. We can always just note in the readme how it's meant to be used. |
I think the 1s timeout is reasonable for a first pass. |

Adds support for

$(command)in label text. The command runs at menu render time and the output replaces the expression. For example a label set to "---$(hostname)" shows the machine hostname as a section header. Works in regular items and labeled separators.