mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.98k stars 715 forks source link

Error on Kitty terminal when executing the new command #4094

Open gustavo-hms opened 3 years ago

gustavo-hms commented 3 years ago

Steps

Outcome

The command fails and the *debug* buffer shows the following message:

shell stderr: <<<
/bin/sh: 2: local: not in a function
>>>

Expected

It should open a new Kitty window running kak.

The problem seems to be in this line and this line. If I remove the local words, the command works.

Screwtapello commented 3 years ago

Yep, Shellcheck reports:

rc/windowing/kitty.kak:18:9: warning: In POSIX sh, 'local' is undefined. [SC2039]
rc/windowing/kitty.kak:36:9: warning: In POSIX sh, 'local' is undefined. [SC2039]

However, local is supported by dash, and bash in POSIX mode. Out of curiosity, what shell are you using?

gustavo-hms commented 3 years ago

I'm using fish. But I think it's not calling fish when executing these commands... At least, %sh{} doesn't.

Screwtapello commented 3 years ago

Yes, Kakoune uses /bin/sh to interpret shell blocks, not your interactive shell. Normally /bin/sh is bash, or a descendent of the Almquist Shell like dash, both of which should support local. Apparently your OS is unusual.

Of course, using local in a Kakoune script is still a bug; even though local is a very common extension to the POSIX standard it's still not a standard feature.

gustavo-hms commented 3 years ago

Hmm... this is odd, since I observed this problem in a Ubuntu machine.