0

In sh-mode I am getting following flycheck-error message:

File Line [v]ColLevel ID Message (Checker) config.sh 2 error Syntax error: "(" unexpected (sh-posix-dash) 

for the following line: strings=("hello" "world") . But this is actually a valid expression in bash.

complete file:

#!/bin/bash strings=("hello" "world") 

init.el file has following lines, reference:

(define-derived-mode my-cfg-mode sh-mode "My CFg Mode" "A mode for my CFg files." (sh-set-shell "bash")) 

Is it possible to suppress this warning message?

7
  • Can't reproduce it: flycheck is happy with it. What does the complete file look like? Is there a shebang on line 1? And what is sh-posix-dash? Commented Dec 6, 2022 at 22:32
  • @NickD sh-posix-dash is one of the shell checkers in flycheck Commented Dec 6, 2022 at 23:00
  • 2
    @alper if you're using bash, use the bash checker. Commented Dec 6, 2022 at 23:00
  • @NickD Yes sir there is #!/bin/bash line (updated on my question). flycheck-sh-posix-dash-executable is set to nil Commented Dec 7, 2022 at 9:51
  • @nega How can I set bash checker from the init.el file? Commented Dec 7, 2022 at 9:52

1 Answer 1

0

As checker sh-posix-dash was enabled. When I add following lines into my init.el file the problem is solved.

(with-eval-after-load 'flycheck (setq-default flycheck-disabled-checkers '(sh-posix-dash))) 

As @Ian mention core cause was due to following lines, hence also removing those lines from my init.el file was also resolved the conflict:

(define-derived-mode my-cfg-mode sh-mode "My CFg Mode" "A mode for my CFg files." (sh-set-shell "bash")) 
2
  • 1
    I think you have a chicken-egg problem: why did you added those three lines in your init.el file? You did not copied the whole example, which defines a derived mode for a .cfg file, while your file is still a .sh file, so you created yourself a problem. Try to remove those lines, you do not need them to have correct behavior. Neither to disable a checker. Commented Dec 8, 2022 at 9:06
  • @Ian Honestly I couldn't remember why I added those three lines(indicated in my question) in my init.el file :-( I was thinking they are required for something I was using but instead they were causing conflict like you mentioned. I updated my answer, please feel free to edit Commented Dec 8, 2022 at 10:27

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.