linux终端中的shell程序

时间:2022-02-01 02:55:04

I wanna make a shell on linux terminal using C, just like "bash", so I used fork() and execvp() to start any program gets written The thing is I wanna support the Up and Down arrows, meaning that when the user hits Up, the last written line is printed and so on, but when I use the usual printf I can't move the cursor around the printed text so I can't modify it, and it won't be taken as an input I tried using getch() and the '\b' option to move the cursor but it still doesn't permit me to modify the text nor will it read the whole line as an input any ideas?

我想在Linux终端上使用C做一个shell,就像“bash”一样,所以我用fork()和execvp()来启动任何程序得到的东西我想支持向上和向下箭头,这意味着当用户点击,打印最后写入的行等等,但是当我使用通常的printf时,我无法将光标移动到打印文本周围,所以我无法修改它,它不会被视为输入我尝试使用getch()和'\ b'选项移动光标,但它仍然不允许我修改文本,也不会读取整行作为输入任何想法?

1 个解决方案

#1


2  

If you use termcaps/ncurses it will help you alot ! Hope it helped.

如果您使用termcaps / ncurses,它将帮助您!希望它有所帮助。

#1


2  

If you use termcaps/ncurses it will help you alot ! Hope it helped.

如果您使用termcaps / ncurses,它将帮助您!希望它有所帮助。