Python_user
Python_user

Reputation: 1574

Creating a customised shell

I have created a customized shell in C++. Currently, the shell is designed as an infinite while loop that is started by running the corresponding executable from the terminal (I am using Ubuntu as my OS). The shell implements a few new commands that are each stored as separate executables in the file system. The rest of the commands that the user enters are directly executed using the execve() wrapper function.

So, essentially, I am executing all the user commands by using the execve() function: the customised commands are stored as separate exectuables and are "execed" by providing the path to the executable whereas any other "standard" unix command is directly execed.

Instead of running it as a separate executable from bash, I want to make the user use my shell that executes on the terminal. How can I do that?

I referred to the following links:

Processes and Sessions and Controlling Terminals

Creating a UNIX shell

However, I am unable to figure to out the links like association between a controlling terminal and the shell etc. Any help would be appreciated in this regards.

UPDATE:

This may sound a bit illogical but:

Is there any way to implement it as a user command that the user can execute from the current shell?I know there is a command called chsh... but will it work with my shell?

Upvotes: 1

Views: 156

Answers (1)

that other guy
that other guy

Reputation: 123410

First you can test your shell from bash with exec yourshell. This replaces the bash process with your shell entirely. (When you exit your shell, the terminal will exit/logout with it.)

You can also run xterm -e yourshell to start an xterm with your shell instead of bash.

If you want to permanently make it your default shell:

  1. Add your shell to the list of system shells, /etc/shells
  2. Change your user's login shell with chsh
  3. Log out and in again

Upvotes: 1

Related Questions