shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

shellcheck doesn't properly handle `tmux -L socketname ...`

Open derekschrock opened this issue 2 years ago • 1 comments

When tmux -L socketname ... and socketname() { ... } both exist shellcheck thinks you're trying to use a function in tmux. tmux -L name ... is the name of the socket file to use for server comm.

For bugs

  • 2032, 2033
  • 0.8.0
  • [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
#!/usr/bin/env bash

test() { :; }
tmux -L test cmd1 ...

Here's what shellcheck currently says:

In test.sh line 3:
test() { :; }
^-----------^ SC2032 (info): Use own script or sh -c '..' to run this from tmux.


In test.sh line 4:
tmux -L test test
        ^--^ SC2033 (warning): Shell functions can't be passed to external commands.

For more information:
  https://www.shellcheck.net/wiki/SC2033 -- Shell functions can't be passed t...
  https://www.shellcheck.net/wiki/SC2032 -- Use own script or sh -c '..' to r...

Here's what I wanted or expected to see:

nothing.

derekschrock avatar May 16 '22 02:05 derekschrock

shellcheck would have the same issue with tmux -c -f -S -T ?

derekschrock avatar May 16 '22 02:05 derekschrock