0

In my Github project I have this snippet in my powershell script:

param (
    [string]$f,
    [string]$l 
)

The Super-linter shows me this error:

SC1036: '(' is invalid here. Did you forget to escape it?

but the code itself works. I also tried a disabling of this linter rule, but this was not working, unfortunately.

Joergi
  • 1,527
  • 3
  • 39
  • 82
  • Looks like the `bash` linter interprets `.ps1` as a shell file extention, you probably wanna add `FILTER_REGEX_EXCLUDE: .*\.ps1` to the `lint_bash` linter step – Mathias R. Jessen Oct 06 '20 at 23:10
  • 3
    Why is there a `#!/bin/bash` shebang in your PowerShell script? This might be why super linter is running shellcheck instead of PSScriptAnalyzer on your script. – Nathan Mills Oct 06 '20 at 23:26
  • oh wow... I will give it a try @NathanMills, thx – Joergi Oct 07 '20 at 07:47
  • 1
    @NathanMills - removing `#!/bin/bash` was the key to success. thanks for pointing it out. If you want, you can write it as an answer, so I can accept it! – Joergi Oct 07 '20 at 16:53

1 Answers1

0

PowerShell scripts shouldn't have #!/bin/bash interpreter line (shebang). This interpreter line might confuse the linter making it run shellcheck (which is for bash/sh scripts) instead of PSScriptAnalyzer (the powershell linter).

The correct interpreter line for PowerShell on Linux/Mac is #!/usr/bin/env pwsh. 1

Nathan Mills
  • 2,243
  • 2
  • 9
  • 15