focusaurus / atom-format-shell

Format shell script from within atom text editor
MIT License
6 stars 1 forks source link

format-shell failed with code 1. #7

Closed leagris closed 5 years ago

leagris commented 5 years ago

Atom 1.30.0 x64 Linux format-shell 2.0.0 shfmt_v2.5.1_linux_amd64

format-shell failed with code 1.

:147:28: test operator words must consist of a single literal

    if [[ "$(confirmUser)" =~^${LMUSER}|(?![aA](?:[bB][oO][rR][tT])?|[qQ]|[xX]|)$ ]];

Fails at the = sign.

focusaurus commented 5 years ago

Looks like you are missing a space after =~ so the formatter can't parse your script. Try fixing that then formatting.

focusaurus commented 5 years ago

I tried your snippet in a test file, reproduced the error, added the missing space, then was able to format the script.

leagris commented 5 years ago

Thank you, I thought the errors were those of the pluggin ^^

focusaurus commented 5 years ago

Right, this message is the formatter saying "I can't format this script because it has this syntax error". This plugin is strictly about formatting. I recommend also installing the linter atom plugin and linter-shellcheck, which will check your script for syntax errors (and other common issues) and highlight them for you as you type. Then once your code passes lint, you can autoformat it.