Go back to command line in bash

346 Views Asked by At

I am using this code to exit my program:


exit(){
        clear
        exit 0
}

This clears the screen, but does not exit the script and just leaves a blinking caret in the terminal. Is it possible that this does not work within a function?

I tried this method to exit:

trap "exit 1" TERM
export TOP_PID=$$

exit()
{
   clear
   kill -s TERM $TOP_PID
}

But this produces a similar result as the first idea.

1

There are 1 best solutions below

0
Cyrus On

Avoid using names of built-in commands as function names. You can get a list of the built-in commands using help.

To answer your question:

Replace exit 0 with command exit 0 to force usage of built-in command.