CC: Tweaked

CC: Tweaked

57M Downloads

too long without yielding - errors using shebangs in combination with shell

hugeblank opened this issue ยท 4 comments

commented

Minecraft Version

1.19.x

Version

1.103.1

Details

As implied by #1273, shebangs are now something that you can use in files. I was hoping I could use this in a shell script but it seems to just cause them to hang. A simple program like:

#!shell
ls

causes a whole range of "Too long without yielding" errors. Here's a few, not sure how useful they'll be though:

  • expect.lua:51: ...
  • bios.lua:22: ...
  • bios.lua:470: bios.lua:32: ...

It's worth noting I've had success with using shebangs in the past. I'm able to use it with an inventory management program that accepts command line instructions, and that works perfectly fine. It's just with shell (the most probable use case for shebangs!) that I can't seem to get it working.

commented

#!shell is not expected to work, as the shell does not support scripting (intentionally so, it doesn't really make sense in CC).

If you run a file foo which starts with #!shell, then that will be expanded to run shell run. However, that in turn just expands to another call to shell.run("foo"), hence the infinite loop.

I think the best thing to do here is just to detect usages of shell with no arguments inside a shebang, and error out with something a little more friendly. It feels a little nasty, but can't think of any alternatives.

commented

#!shell is not expected to work, as the shell does not support scripting (intentionally so, it doesn't really make sense in CC).

I can think of a few use cases where it would make sense:

  • Small startup scripts that launch applications that you normally use.
  • Quickly copying, moving and deleting files.

I think implementing this as something that actually functions could encourage newer players to mess around with making their own smaller scripts that add more commands to the shell. For example the first use case I provide wouldn't work unless the player made a script that switches the tab for them, sending them down a rabbit hole learning about the multishell API. I could go on, but the gist of what I want to get across is that this should really be considered as a feature.

commented

#!shell is not expected to work, as the shell does not support scripting (intentionally so, it doesn't really make sense in CC).

I can think of a few use cases where it would make sense:

* Small startup scripts that launch applications that you normally use.

* Quickly copying, moving and deleting files.

I think implementing this as something that actually functions could encourage newer players to mess around with making their own smaller scripts that add more commands to the shell. For example the first use case I provide wouldn't work unless the player made a script that switches the tab for them, sending them down a rabbit hole learning about the multishell API. I could go on, but the gist of what I want to get across is that this should really be considered as a feature.

I might have read this wrong but I've gotten the impression that shebangs become their own scripting language.

commented

CC already has one scripting language. It doesn't need another one!

While I say this somewhat in jest, I do think dumping two "languages" on people starting off with the mod is a mistake - people already try to run Lua code in the shell prompt, trying to promote shell scripting as a beginner-friendly option can only make things worse. I'd much rather we spent time improving the docs to make learning the APIs easier, rather than trying to teach two separate systems.

Quickly copying, moving and deleting files.

With the exception of globs, you can do any of these with one call to an fs function.

Small startup scripts that launch applications that you normally use.

There's no harm with people doing shell.run("fg foo"). Though also note that launching a tab and switching to it is already documented.