set -e
causes the shell to exit if any subcommand or pipeline returns a non-zero status.
The answer the interviewer was probably looking for is:
It would be dangerous to use “set -e” when creating init.d scripts:
From http://www.debian.org/doc/debian-policy/ch-opersys.html 9.3.2 —
Be careful of using set -e in init.d scripts. Writing correct init.d scripts requires accepting various error exit statuses when daemons are already running or already stopped without aborting the init.d script, and common init.d function libraries are not safe to call with set -e in effect. For init.d scripts, it’s often easier to not use set -e and instead check the result of each command separately.
This is a valid question from an interviewer standpoint because it gauges a candidates working knowledge of server-level scripting and automation
Related Posts:
- Given two directory trees, how can I find out which files differ by content?
- Diff command along with Grep gives “Binary file (standard input) matches”
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Command to change the default home directory of a user
- What does “&” at the end of a linux command mean?
- Syntax error near unexpected token ‘then’
- How do I grep recursively?
- How do I grep recursively?
- How do I grep recursively?
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How to perform grep operation on all files in a directory?
- subprocess.Popen(): OSError: [Errno 8] Exec format error in python?
- How to substitute shell variables in complex text files
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- SSH using python script
- Curl command for https ( SSL )
- How can I exclude directories from grep -R?
- How to exclude a directory in find . command
- “sed” command in bash
- How can I exclude directories from grep -R?
- How to exclude a directory in find . command
- Shell command to tar directory excluding certain files/folders
- Argument list too long error for rm, cp, mv commands
- Difference between using “chmod a+x” and “chmod 755”
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Who can access a file with octal permissions “000” on Linux/UNIX?
- How to cat <
> a file containing code? - Extract file basename without path and extension in bash
- Pseudo-terminal will not be allocated because stdin is not a terminal
- screen Cannot open your terminal ‘/dev/pts/0’ – please check
- ./configure : /bin/sh^M : bad interpreter
- How to download a file from server using SSH?
- Is there a “goto” statement in bash?
- Implementing shell in C and need help handling input/output redirection
- What does `set -x` do?
- Writing a simple shell in C using fork/execvp
- Implementation of multiple pipes in C
- chmod: changing permissions of ‘my_script.sh’: Operation not permitted
- Using ls to list directories and their total sizes
- Can’t remove a directory in Unix
- What does set -e mean in a bash script?
- What does set -e mean in a bash script?
- C fopen vs open
- Using grep and ls -a commands
- How to use sed to extract substring
- Restarting cron after changing crontab file?
- How do I write stderr to a file while using “tee” with a pipe?
- cd into directory without having permission
- How do I know the script file name in a Bash script?
- Copying a large directory tree locally? cp or rsync?
- Can I nohup/screen an already-started process?
- Environment variables of a running process on Unix?
- In my /etc/hosts/ file on Linux/OSX, how do I do a wildcard subdomain?
- Shell command to monitor changes in a file
- When does /tmp get cleared?
- SSL Certificate Location on UNIX/Linux
- Is it possible to detach a process from its terminal? (Or, “I should have used screen!”) [duplicate]
- What is “-bash: !”: event not found”
- Meaning of directories on Unix and Unix like systems
- How to add a timestamp to bash script log?
- How to remove empty/blank lines from a file in Unix (including spaces)?
- How to forcibly close a socket in TIME_WAIT?
- Colors in bash after piping through less?
- How can I kill all stopped jobs?
- How can I rename a Unix user?
- How to run command as user who has /usr/sbin/nologin as Shell?
- How to get pid of just started process
- Can you have more than one ~/.ssh/config file?
- How to disable everything in crontab -l?
- How to sort ps output by process start time?
- Is there a way to do a remote “ls” much like “scp” does a remote copy?
- How do I join two named pipes into single input stream in linux
- How do I pause my shell script for a second before continuing?
- What’s a .sh file?
- In the shell, what does ” 2>&1 ” mean?
- How to fix ‘sudo: no tty present and no askpass program specified’ error?
- How can I find all *.js file in directory recursively in Linux?
- ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known
- How to open some ports on Ubuntu?
- -bash: fork: Cannot allocate memory
- Bash script: bad interpreter
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
- How to include file in a bash shell script
- Does Mac OS X use Linux?
- bash sh – command not found
- Hosting multiple WordPress sites on single server – best practices?
- What permissions should my website files/folders have on a Linux webserver?
- Can I automatically add a new host to known_hosts?
- How can I run Debian stable but install some packages from testing?
- Meaning of the buffers/cache line in the output of free
- How to cd into a directory with this name “-2” (starting with the hyphen)?
- how to disable SSH login with password for some users?
- What’s the best way to check if a volume is mounted in a Bash script?
- How do I find the UUID of a filesystem
- Find out symbolic link target via command line
- How to handle security updates within Docker containers?
- Is it possible to make Nginx listen to different ports?
- REJECT vs DROP when using iptables