-
-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple shell commands in bash= call fail #786
Comments
From the guide: shell=.. to make the item run a given script terminal with your script e.g. shell=/Users/user/xbar_Plugins/scripts/nginx.restart.sh if there are spaces in the file path you will need quotes e.g. shell="/Users/user/xbar Plugins/scripts/nginx.restart.sh" (bash is also supported but is deprecated) So putting commands after shell= isn't allowed. I discovered a trick that works (for me). Create a dummy script that does nothing, then pass it a parameter beginning with a ; (semicolon). This "tricks" xbar into executing the parameters. The dummy script goes in a sub-folder of xbar's plugins, it should only have a single line: #!/bin/zsh Here are your commands setup to use the trick (... is the path to xbar's plugins): This is what Terminal shows as the command it received from xbar: Some observations about your code snippet
Clear as mud? |
Thank you for your reply. Cyborg Sam> From the guide:
I'm aware, that bash is deprecated and yes, quoting is essential.
I'm not sure, I've contacted Mat and he asked me to file an issue, because he thinks it should work. Thank you for the trick, I already saw people putting their commands in the plugin, which get executed by passing a parameter, so it knows what to do.
Nice trick, but feels it little bit like sql injection ;-)
I know, I had to strip down my real process, it is much more complex.
Not always, have a look at 3.
I know how && works. I left this in intentionally, because I wanted to make sure, that if there is a bugfix, it will also work as ; . But after 30 years doing Unix scripting I came across || a few days ago. || is the OR operator. It executes the command on the right only if the command on the left returned an error ;-) |
I'm glad your level of expertise is high, it will help the developers fix this issue. I use the test && a || b structure a lot when a and b are short statements. I have no proof of this (didn't check the source code) but it appears xbar isn't parsing either shell= nor param1= correctly. Pass param1="cd $HOME/Library" and the quotes are removed and it becomes two parameters. I couldn't find a way to quote param1 so the quotes survived xbar's parsing. |
|
I have this same issue. A really simple one that fails is:
This generates the same issue. This used to work in BitBar, but now I am struggling. I have giant scripts that have multiple entries which runs commands like this and I am struggling to find a nice solution (having many extra script files seems to remove simplicity I have enjoyed in BitBar). |
As a workaround I have found that this seems to work:
|
This is very strange, but that workaround gives us some interesting clues. Thank you. |
Hey 👋 I had the same issue, I was trying to call a small bash function defined in the same plugin file, like that: if [ "$1" = 'connect' ]; then
# do something
fi
echo "🐼"
echo "---"
echo "Connect to VPN | shell='$0' param1=connect terminal=true" and I was getting this error:
where I changed the shell call to use the absolute path and now it works 🎉 echo "Connect to VPN | shell='/Users/nicolo.gnudi/Library/Application Support/xbar/plugins/$0' param1=connect terminal=true" Hope it helps ✌️ |
While converting my Bitbar configuration to xbar, I figured out that the bash directive is not working as before. I automated my personal tasks with the bash= directive by concatenating several shell commands with &&. For example: changing shell color, setting correct JAVA version, building and starting SpringBoot application. The following plugin code is stripped down the minimum.
After selection, the menu item, the shell is going to show this
zsh: no such file or directory: (cd $HOME/Library && ls -l)
Enclosed you'll find a simplified version of such a plugin written in perl.
xbarSample.1d.pl.txt
The text was updated successfully, but these errors were encountered: