質問

For clearing screen in shell code if we write CTRL + L we do

printf "\033c"

then what shall be done for CTRL + C ?

just exit is not working in my code because i am handling errors and in case of bad inputs i have to run code again and for that when i am unseting variables by unset it is working fine but later again my code shows output with no input variables.

役に立ちましたか?

解決

If I understand correctly what you want to do, you should use the trap command. trap prevent the shell default handling and allows you to interrupt, quit, hangup etc. what you were doing.

The syntax is the following

trap <command to execute> <signal to intercept>

so you could do something like

trap break INT

to have the equivalent of a Ctrl-C.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top