Skip to content
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

Shell action can't parse element like '&&' correctly #402

Open
jiengup opened this issue Jan 4, 2024 · 7 comments
Open

Shell action can't parse element like '&&' correctly #402

jiengup opened this issue Jan 4, 2024 · 7 comments
Labels
bug Something isn't working
Milestone

Comments

@jiengup
Copy link

jiengup commented Jan 4, 2024

As in https://github.com/matryer/xbar-plugins/blob/main/Dev/Homebrew/brew-updates.1h.rb#L306
if writing in ruby like:

if all_casks.size.positive?
            cmds << '&&' if cmds.size.positive?
            cmds += [brew_path, 'upgrade', '--cask'] +
                    all_casks.map(&:name)
          end

          printer.item(
            "⬆️ Upgrade All (#{all_formulas.size + all_casks.size})",
            terminal: true, refresh: true,
            bash: (cmds + post_commands).flatten
          )

then the shell will run like this:

/opt/homebrew/bin/brew upgrade --formula c-ares cmake coreutils d2 fd
 gawk gcc git-lfs go gperftools lf libpthread-stubs libssh lua mpfr node openssl
@1.1 [email protected] qemu smartmontools texinfo tree typst wimlib yarn '&&' /opt/homebrew/bin/brew upgrade --cask ipatool

however zsh can not accept '&&' as && or ';' as ; and raise an error.

@melonamin
Copy link
Contributor

@jiengup I'm not sure what is the question here.

You can either rewrite the plugin to generate a zsh compatable script, or switch execution in SwiftBar from zsh to bash.

@jiengup
Copy link
Author

jiengup commented Jan 4, 2024

@jiengup I'm not sure what is the question here.

You can either rewrite the plugin to generate a zsh compatable script, or switch execution in SwiftBar from zsh to bash.

I think it may be that swiftbar's string parser does something like "add quotas between some specific string"?
Cause when I choice "run in terminal" and get something like

--⬆️ Upgrade All (26) | terminal="true" refresh="true" bash="/opt/homebrew/bin/brew" param1="upgrade" param2="--formula" param3="c-ares" param4="cmake" param5="coreutils" param6="d2" param7="fd" param8="gawk" param9="gcc" param10="git-lfs" param11="go" param12="gperftools" param13="lf" param14="libpthread-stubs" param15="libssh" param16="lua" param17="mpfr" param18="node" param19="[email protected]" param20="[email protected]" param21="qemu" param22="smartmontools" param23="texinfo" param24="tree" param25="typst" param26="wimlib" param27="yarn" param28="&&" param29="/opt/homebrew/bin/brew" param30="upgrade" param31="--cask" param32="ipatool"

Please notice param28 above
But when I click this ⬆️ Upgrade All (26) in menubar, the terminal will run:

/opt/homebrew/bin/brew upgrade --formula c-ares cmake coreutils d2 fd
gawk gcc git-lfs go gperftools lf libpthread-stubs libssh lua mpfr node openssl@
1.1 [email protected] qemu smartmontools texinfo tree typst wimlib yarn '&&' /opt/homebrew/bin/brew upgrade --cask ipatool

Plese notice '&&' above, other params can be parsed without ', which work perfectly.
And the shell will not recognize this expression and take '&&' as some kind of parameters then fail to run.

Please tell me if I'm mistaken on this issue and if it's because of some features of zsh or ruby language.

@melonamin
Copy link
Contributor

Ah, got it. Sorry, early morning comment:)

Yeah, you're right, this is might be quating\escaping I've added in the latest release, let me look into it.

@melonamin melonamin added the bug Something isn't working label Jan 4, 2024
@melonamin melonamin added this to the 2.0.1 milestone Jan 4, 2024
@melonamin
Copy link
Contributor

@jiengup can you check if beta build fixes this?

@jiengup
Copy link
Author

jiengup commented Jan 5, 2024

@melonamin Yep, I just install beta build and test it. It works perfectly. Nice job! I'll keep using this beta version and give feedback. Thank you for getting back to me.

@jiengup jiengup closed this as completed Jan 6, 2024
@jiengup jiengup reopened this Jan 7, 2024
@jiengup
Copy link
Author

jiengup commented Jan 7, 2024

@melonamin Sorry, I found it will not work perfectly when I write in python like

bash="/usr/bin/vim", param1="~/.vimrc"

Swiftbar will produce output /usr/bin/vim "~/.vimrc" and vim will take it as a directory instead of a normal file.
image
I think it's related to this issue.

@incanus
Copy link
Contributor

incanus commented Jan 12, 2024

I came here after digging around with the same issue, formerly-working && in params now not working in 2.0. Using the beta build fixes it for me, too.

melonamin added a commit that referenced this issue Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants