matryer / xbar-plugins

Plugin repository for xbar (the BitBar reboot)
https://xbarapp.com
2.44k stars 1.04k forks source link

Improved "shell" documentation with quotes and how to call itself #2022

Closed alessio-signorini closed 5 months ago

alessio-signorini commented 5 months ago

Having a plugin that supports being called with multiple parameters would be useful, e.g.,

if [ "$#" -ne 1 ]; then
   ...default operation...
endif

if [ "$1" = "reboot" ]; then
   ...reboot operation...
endif

While the documentation suggests using bash=$0 for the script to call itself until tonight I was not able to make it work correctly due to issues with the running path.

I decided to improve the "shell" documentation including an example on how to make the script call itself correctly using $(realpath $0).