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

[prettier-plugin-sh] Incorrect formatting breaks the script (zsh) #399

Open
1 task done
korikhin opened this issue Dec 31, 2024 · 0 comments
Open
1 task done

[prettier-plugin-sh] Incorrect formatting breaks the script (zsh) #399

korikhin opened this issue Dec 31, 2024 · 0 comments

Comments

@korikhin
Copy link

Hi! I've encountered some issues formatting zsh flavoured script (*.zsh).

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Suppose I want to check if some command exists with the script below:

#!/usr/bin/env zsh

if (( $+commands[cat] )); then
    echo "ok"
fi

After formatting You will see:

#!/usr/bin/env zsh

if (($ + commands[cat])); then
    echo "ok"
fi

This will raise an error:

./test.zsh:3: bad math expression: operand expected at '/bin/cat'

So You are forced to use quotation:

#!/usr/bin/env zsh

if (("$+commands[cat]")); then
    echo "ok"
fi

After formatting it still lacks padding spaces.

Desired behaviour: (( "$+commands[cat]" )) or (( $+commands[cat] ))

Thanks!

@korikhin korikhin changed the title Incorrect formatting breaks the script (zsh) [prettier-plugin-sh] Incorrect formatting breaks the script (zsh) Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant