shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

Accept .sh.file variable for ksh scripts

Open cpassuel opened this issue 2 years ago • 1 comments

For bugs

  • Rule Id (if any, e.g. SC1000): SC2296
  • My shellcheck version (shellcheck --version or "online"): online
  • [x] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • [x] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit

For new checks and feature suggestions

  • [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
  • [x] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related

Here's a snippet or screenshot that shows the problem:

#!/bin/ksh
echo "INFO Init ${.sh.file} script"

Here's what shellcheck currently says:

echo "INFO Init ${.sh.file} script"
                  ^-- SC2296 (error): Parameter expansions can't start with .. Double check syntax.

Here's what I wanted or expected to see: I expect that.sh.file is accepted as it is used to retrieve the script location inside a sourced script https://unix.stackexchange.com/a/96238

cpassuel avatar May 17 '23 12:05 cpassuel

the tile should be changed as this affects all ksh name space variables beginning with . not only the built-in .sh name space

I also notice ksh's namespace command causes parsing to stop (SC1089) as noted in #2245

dicktyr avatar Apr 25 '24 18:04 dicktyr