Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hello everyone,
I've been bitten by a linux bug and now want to develop a new shell of mine. I think I will modify the bash shell to begin with and learn how stuff works.
If someone can give me some pointers about how to take the first few steps, it would be great.
1) I have downloaded the bash 4, source code. Things look a little daunting, I am not an uber lex/yacc/C hacker.
2) I want to develop a shell/modify the bash shell, such that I can specify a command/input that must be typed in the shell for it to start working.
an example: say I made a shell called mystupidshell, and configured my system such that whenever someone logs in, thats the default shell. I want them to type in their name at the prompt first and then type in the commands they want to use like ls, cd.. if they don't type in their name and instead type in ls etc.. they should be shown a msg saying whats your name nd then move on to let them type in various commands.
To do this where can I start in the bash code to analyze and make changes. Should I look at shell.c?
No idea, but I can already tell you that your shell
won't be very popular. What's the objective behind
this? If you don't want people to use the machine,
just don't give them access ;D
@neonsignal
Thanks for the link, I will definitely look it up.
You are on the money about bash code needs a little getting used to .. especially for newbies like me.
I was wondering if there is a forum more dedicated for bash specific issues, I did try searching groups.google.com for "bash code" etc.., but I got answers all over the place.
Even though I will take a look at the simpleCshell, I would like to stick to hammering it out with bash. It'll be painful I think but I expect I'll learn a lot.
Thanks again everyone, and any starter tips would be greatly appreciated.
Just to restate: I want that when the shell is spawned, the user will enter his/her name and then continue normal operation. Where could I concentrate to plug in my code to accept input and throw operation into normal mode.
Also, another wild thought: is it feasible to somehow spawn a vanilla bash shell, somehow pipe (I know its not the right word) the output to my "name-accepting" program and then throw the user back to the vanilla bash?
Hello helpful people,
Can someone please provide me with an idea regarding why my 2 lines inserted into main bash code seem to produce an error msg.
My goal is to intercept the command typed and to write it out to a buffer file for further processing and hand control back to standard bash execution.
I inserted
Code:
if (command != 0) {printf("aiiiiiiii\n");}
in execute_cmd.c in the latest bash-4.0 code right before it uses the COMMAND_NOT_FOUND hook. Before hookf = find_function (NOTFOUND_HOOK); approx line # 4451
I set up a test user on my system, changed the default shell to newly compiled shiny shell and logged in only to get
Code:
aiiiiiiii
aiiiiiiii
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: [: too many arguments
-bash: complete: aiiiiiiii: no completion specification
bogus@mycomp:~$ ls /ho
malloc: /Users/chet/src/bash/src/parse.y:5561: assertion botched
free: called with unallocated block argument
last command: (null)
Aborting...Connection to 127.0.0.1 closed.
I looked up the error code and it matches with an entry for a bash bug http://osdir.com/ml/bug-bash-gnu/2009-04/msg00132.html
and it seems there is a patch for the bug.. but I just inserted 2 lines of code in there. I don't profess to be a C guru, but there's little scope for error in the 2 lines of code!
any suggestions?
Last edited by anirvana; 09-11-2009 at 10:06 PM.
Reason: missplet Hello as Hell
Hell helpful people,
Can someone please provide me with an idea regarding why my 2 lines inserted into main bash code seem to produce an error msg.
[ snip ]
I looked up the error code and it matches with an entry for a bash bug http://osdir.com/ml/bug-bash-gnu/2009-04/msg00132.html
and it seems there is a patch for the bug.. but I just inserted 2 lines of code in there. I don't profess to be a C guru, but there's little scope for error in the 2 lines of code!
any suggestions?
A few. This is not how one learns how to write computer programs.
1. Start small. Write your own command shell and test it. Make sure it works.
2. Add more sophisticated operations to your shell. Test them.
3. Never move ahead if anything happened that you didn't understand. Instead, analyze the operation of your program -- why it succeeded as well as why it failed.
I have to say that hacking the source for Bash, adding lines and discovering it won't compile but not understanding why, is the least productive imaginable way to learn computer programming.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.