rohanchandra / javascript-terminal

JavaScript terminal emulator library that works in Node.js and your browser.
https://rohanchandra.gitlab.io/javascript-terminal/demo/
MIT License
117 stars 36 forks source link

shell scripts #15

Open adamwong246 opened 4 years ago

adamwong246 commented 4 years ago

Whats the best way to run a series of commands a la a shell script?

rohanchandra commented 4 years ago

Given the scope of this project, unfortunately, there's not nice way to run a script of commands.

The command parser does support the && operator to chain commands, like echo "a" && echo "b".

Here's how I would approach this problem:

  1. Before calling emulator.execute, do your own parsing of commandStr to check if it should be run as a series of commands
  2. If so, chain the commands with && then call emulator.execute

Hope that helps!