Code Monkey home page Code Monkey logo

cash's Introduction

ComputerCraft Advanced Shell

A Bourne-compatible shell for ComputerCraft.

image

Features

  • Bash/sh-style command line
  • Tab completion (defaulting to file names where not supported)
  • Customizable prompts (including ANSI support)
  • Local & environment variables
  • Argument quoting
  • Multiple commands on one line with semicolons
  • Many built-in functions (including in-line Lua commands)
  • Arithmetic expansion
  • If, while, for statements
  • Function support
  • Shell scripting/shebangs
  • Background jobs
  • rc files
  • Restorable history
  • Job control, pausing
  • Partial CCKernel2 support
  • Full compatibility with CraftOS shell.lua

Missing features

  • Backtick/command substitution
  • Pipes/console redirection/here documents

TODO

  • Add test boolean operators (-a, -o)
  • Add case statement

License

This project is licensed under the MIT license. You are free to modify and redistribute cash.lua as long as the copyright notice is preserved at the top of the script.

cash's People

Contributors

mcjack123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cash's Issues

Compatibility + terminate event

I would suggest having some boolean at the start to determine if you are running within your custom kernel. Also check more than just if the global kernel exists (ie. kernelMode = kernel and users and kernel.getPID).

Also, when a program is run under this shell, the terminate event is not being processed correctly. An example would be if the program being run is waiting for read() to finish and receives a terminate event. Currently, both the program and the shell are terminated.

Unable to terminate shell

All is looking good but I have one last issue. If I run cash.lua, I am not able to terminate it directly - I must use the exit command. I believe the cash process should handle the terminate event and exit accordingly.

Incorrect terminal after terminate

With the latest changes, the terminal is not being correct set for resume/terminate.

You might want to use something like this in order to support programs that do term redirection:

		local previousTerm = term.redirect(self.terminal)

		local ok, result = coroutine.resume(self.co, event, ...)

		self.terminal = term.current()
		term.redirect(previousTerm)

This keeps a terminal handle associated with each coroutine (multishell does something similar as well).

This is the code for opus task coroutine manager: [https://github.com/kepler155c/opus/blob/1e675a2e3523411b45655e450be62b137f41230a/sys/kernel.lua#L85]
I have been testing this shell with Opus OS checking for compatibility. If you wanted to give it a shot, you would run pastebin run uzghlbnc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.