custom linux shell that can run bash shell

151 views
Skip to first unread message

Harsh Rathore

unread,
Jun 3, 2022, 11:26:52 AM6/3/22
to golang-nuts
Hello everyone,
so I am trying to make a custom linux shell in golang, among other things, I want this shell to be able to run BASH shell.

Like when we are prompted with sh shell
$
executing /bin/bash, provides bash prompt
$ /bin/bash
user@hostName:~#

similarly, I want my golang shell to provide me with bash shell
myPrompt> /bin/bash
user@hostName:~#

I have tried multiple things:
1. Replicating bash prompt, when /bin/bash is received, and getting os.Stdin, and executing using os/exec Output() function.
2. Trying to make stdpipes and then channel input/output via them, while using cmd.Start() and cmd.Waint().

these did not help, I am looking for some help from the experts.
Thank you if you read this.
Super thank you, if you have a solution :).

PFA: My shell.go file. 
shell.go

Roland Müller

unread,
Jun 4, 2022, 11:38:31 PM6/4/22
to golang-nuts
Hello,


Am Freitag, 3. Juni 2022 schrieb Harsh Rathore <hvrcon...@gmail.com>:
> Hello everyone,
> so I am trying to make a custom linux shell in golang, among other things, I want this shell to be able to run BASH shell.
> Like when we are prompted with sh shell
> $

Of course it is feasable to make a Golang remake of interactive or batch processing Linux shell. However doing that you have to answer the question why a Golang rewrite would be better than just using the existing shell(s).

BR,
Roland

> executing /bin/bash, provides bash prompt
> $ /bin/bash
> user@hostName:~#
> similarly, I want my golang shell to provide me with bash shell
> myPrompt> /bin/bash
> user@hostName:~#
>
> I have tried multiple things:
> 1. Replicating bash prompt, when /bin/bash is received, and getting os.Stdin, and executing using os/exec Output() function.
> 2. Trying to make stdpipes and then channel input/output via them, while using cmd.Start() and cmd.Waint().
> these did not help, I am looking for some help from the experts.
> Thank you if you read this.
> Super thank you, if you have a solution :).
> PFA: My shell.go file. 
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/fa86ccc6-c847-4c8f-bea3-65b938b0d4cdn%40googlegroups.com.
>
Reply all
Reply to author
Forward
0 new messages