Hello,

I'm trying to write a bash shell script to run some finalization commands on cygwin under Windows XP. I'd like to exit the shell in an automatic way (writing the 'exit' command in the script) but it doesn't work.

Do anybody knows a way to do that?

Recommended Answers

All 3 Replies

exit in the script, or any thing else designed to exit the shell, will only exit
the subshell that the script is operating under (that #! line at the top of
the script). If you want your login shell to exit with the script then you
have to execute the script as "exec scriptname" rather than just
"scriptname". This way, when the script ends, the login shell ends.

or try

. myscript.sh
#or
source .myscript.sh

Thanks a lot masijade and mcnamara! :)

I've found the dot way (. myscript) the most comfortable, but they all works fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.