allow Vorpal to run arbitrary bash commands and pipe back to shell
See original GitHub issueMy Vorpal options are like so:
Commands:
help [command...] Provides help for a given command.
exit Exits application.
pwd echo present working directory
run [file] run a single test script
find [options] find test files to run
I’d like to be able to type a command - if it’s not a recognized option - to send it to bash and have bash interpret it.
One thing I could do is create a new option
bash [command...]
and then I could send all the arguments to bash that way…
however that requires users to type in something like:
> bash "ls -a"
or
> bash "ps aux | grep node"
like I said, it would be cool to be able to give Vorpal the option of sending unrecognized commands to bash and then piping the results back to vorpal terminal.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
bash - Execute a command once per line of piped input?
The accepted answer has the right idea, but the key is to pass xargs the -n1 switch, which means "Use at most 1...
Read more >vorpal - Bountysource
I'm emulating a virtual real-world device that does a thing on an interval. When I ctrl-c ctrl-c to exit that device, that interval...
Read more >How to pipe multiple commands into a single command in the ...
Use parentheses ()'s to combine the commands into a single process, which will concatenate the stdout of each of them. Example 1 (note...
Read more >Jari's Procmail Tips Page - Howtoforge
8.7 How to run an extra shell command as a side effect? ... Procmail manual pages exists primarily on Unix/Linux platform, If You're...
Read more >Awkward – A Node.js-based terminal emulator | Hacker News
(you could of course alias those to make 'pidof node' like Linux ... use case (ps -ef printing a nice text table) and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ORESoftware Hmm… maybe I’m missing something - but I think
exec
is the one to use if we don’t want to parse the string, since the signature forspawn
requires the first param to be the command-to-run, and then an array of arguments to pass into that command.For example: Command:
ls -a "dog bear cat" | grep "sally road"
Using
spawn
:spawn(ls, ['-a', '"dog bear cat"', '|', 'grep', '"sally road"'])
Using
exec
:exec('ls -a "dog bear cat" | grep "sally road"')
Plus,
spawn
requires us to read fromstdout
and\orstderr
to get the result, where asexec
will provide the results to the callback - so maybe it’s a better fit in this specific use case?Back to the raw-string issue Yes, a full solution will need to keep track of control-characters - such as line-feed, carriage-return, backspace, cursor-moves etc… - BUT - it’s not that hard to implement - definitely doable (perhaps I’ll have time for that next weekend).
Also, we could publish it as a
vorpal
extension \ plugin - something likevorpal-shell-fallback
. This will be a cleaner way to use, and will allow anyone to add it just by doingvorpal.use('vorpal-shell-fallback')
Here is an updated version that works well. It gets the raw input from the user and passes it to the shell.
Seems to handle opts and args gracefully: