3

What does the set -e command do in SHELL scripting?

Like the following command:

set -e

Can we do any other things with set -e operation?

2 Answers 2

5

The 'set' command is used set and examine shell options, as well as set positional parameters.

The -e flag does the following:

  -e  Exit immediately if a command exits with a non-zero status.

Hope this helps :)

2
  • I have one more doubt what does 'echotime' statement does ?\
    – Kaushik
    Jan 24, 2014 at 16:25
  • 1
    @karthik, I'm unsure about that one - I'd recommend creating a new question so somebody else can aid you
    – vxstorm
    Jan 24, 2014 at 16:30
2

Using the flag -e you ensure stops the execution if a command during the execution has an error. The default behaviour is to ignore the errors in script executions.

If you want to manage this errors, you can use the command "trap".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.