GithubHelp home page GithubHelp logo

trybash / bash-emulator Goto Github PK

View Code? Open in Web Editor NEW
39.0 6.0 17.0 157 KB

Emulate a bash environment in plain JS. In your browser.

Home Page: https://trybash.github.io/bash-emulator

License: MIT License

JavaScript 92.05% HTML 7.95%

bash-emulator's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bash-emulator's Issues

bug in cp using cp -R /

$ cp -R / /backup
$ ls
README.txt backup backupREADME.txt backuphome home

hi

Using cp -R / /backup does not work like it should ๐Ÿ˜ญ

@jorinvo maybe you know how to fix it?

uniq

Implement uniq command.

Add comments with inline documentation

We tried writing the code as simple, modular and straight-forward as possible, but it would be still better to have some explanation about what certain modules and functions do.
I think it wouldn't even be necessary to just an official documentation style and document every parameter.
I'm more thinking about having some introduction at the to of each file. It should be simpler for new contributors to see what the different parts of the project do.

mkdir -p

Should be easy to add the -p flag to mkdir.

head

Implement head command.

tail

Implement tail command.

Symbolic links

Right now the only file types we have are file and dir.

simlink could be an additional one.
We would need to think about the implementation but it shouldn't be too difficult.

With this we should also implement the ln -s command.

commands prio

  • cp a b
  • mkdir
  • touch
  • rm
  • rm -R
  • rmdir
  • mv -n
  • ls -l
  • cp -R

Globbing for file paths

It would be nice to be able to expand file paths using the * operator.
This should be implemented in a reusable way so all system methods could use it.

For now the simple * would be good enough.
Later on we can still at **.

Pipes and Redirection

We already have some chapters prepared for our game to teach about pipes | and redirection< / >.

This can be implemented in a generic way in the .run() system method.

The command interface is already designed in a way to allow streaming of input and output.

  • |
  • <
  • >
  • >>

Logic operators

We could implement && and || operators the same way we would implement pipes and redirection.

Commands are already designed to give us the exit codes which we can use for the logic operations.
Another thing we could implement is the ; to separate lines.

However, I don't think we should try implementing more complex scripting features (like loops and functions).

sort

Implement sort command.

run should reset completion index

If I understand correctly, there's an internal completion.index that keeps track of the last given completion. This variable should be reset when running a command, or otherwise the completion behaviour will be quite weird.

Add clear command to demo

Clear should be implemented by the demo itself since clearing the screen is specific to each terminal.

add sample for async system implementation

The API of the emulator is built with Promises to allow an asynchronous implementation.
The current implementation is all synchronous, in the browser.
All the commands are designed in a way to only interact with the state through the "system calls".
This way it should be possible to implement the "system calls" asynchronous without changing the commands.

An asynchronous implementation could run the system calls on a server for example, persist them or even allow multiple users to interact with the same system this way.

Even better would be to think first about further decoupling the system from the index.js file. Would be nice to be able to choose with which system to initialize the emulator instance.

echo

echo command.

Only use after implementing #15.

think about changing file system structure to a tree

Right now the file system is a flat structure.
This makes some operations easier. And it makes other more difficult.
The biggest issue is that the user can create a structure with holes. If the file system is not connected anymore, it's not really possible to navigate, it's broken.
Also a tree might be easier for the user to create.
Have to see how difficult it would be...

Tab-completion

It would be nice if commands and directories could be completed using the tab key.

We should start with the easiest solution we can find and enhance it later on.

wc

Implement wc command.

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.