Linked Questions

628 votes
10 answers
275k views

I have a Bash shell script that invokes a number of commands. I would like to have the shell script automatically exit with a return value of 1 if any of the commands return a non-zero value. Is this ...
Jin Kim's user avatar
  • 18k
1 vote
2 answers
7k views

If I do a simple test of exit codes directly with single commands: [user@localhost ~]$ date Tue Sep 8 14:00:11 CEST 2020 [user@localhost ~]$ echo $? 0 [user@localhost ~]$ dat bash: dat: command not ...
Zumo de Vidrio's user avatar
2 votes
3 answers
1k views

I have a simple ruby script which uses the abort function to exit with a non-zero exit code #!/usr/bin/env ruby puts "I ran" abort "Exiting" How can I capture the exit code when I execute this ...
dopplesoldner's user avatar
1190 votes
12 answers
803k views

I'm studying the content of this preinst file that the script executes before that package is unpacked from its Debian archive (.deb) file. The script has the following code: #!/bin/bash set -e # ...
AndreaNobili's user avatar
  • 43.3k
31 votes
5 answers
66k views

I saw the code written somewhere online, and I wanted to know what exactly does "$?" do/give us. Googling did not help. Here's the code I saw it in: #!/bin/sh ping -c 2 localhost if [ $? != 0 ] ; ...
Khushman Patel's user avatar
19 votes
6 answers
31k views

I use a Makefile (with GNU make running under Linux) to automate my grunt work when refactoring a Python script. The script creates an output file, and I want to make sure that the output file remains ...
Omer Zak's user avatar
  • 1,167
39 votes
2 answers
15k views

I see here that testing whether $? is zero (success) or something else (failure) is an anti-pattern, but I have not been able to find this anywhere else. Sticking to the definition of anti-pattern of ...
svye's user avatar
  • 493
25 votes
3 answers
11k views

There are a bunch of managed cloud based hosting services for nodejs out there which seem relatively new and some still in Beta. Yet another path to host a nodejs app is setting up a stack on a VPS ...
Yousef Salimpour's user avatar
14 votes
2 answers
22k views

Within my shell script I run this command: python script.py I was wondering, as a two part question: How can I program my python script to pass a status back to the shell script that ran it depending ...
Jimmy's user avatar
  • 12.6k
26 votes
1 answer
6k views

How can I check the exit code of a command substitution in bash if the assignment is to a local variable in a function? Please see the following examples. The second one is where I want to check the ...
Vampire's user avatar
  • 39.2k
6 votes
1 answer
9k views

I am having the following plugin to run a .sh script: <plugin> <artifactId>exec-maven-plugin</artifactId> <groupId>org.codehaus.mojo</groupId> <executions> ...
Schütze's user avatar
  • 1,084
0 votes
2 answers
2k views

Lets say a program that outputs a zero in case of success, or 1 in case of failure, like this: main () { if (task_success()) return 0; else return 1; } Similar with Python, if ...
user1135541's user avatar
  • 1,911
0 votes
2 answers
3k views

I have done a file named hosts.txt which includes some websites, to test the ping on each website with a script. What I want to do with my script is I want to loop through each line that includes ...
Tomb_Raider_Legend's user avatar
2 votes
1 answer
2k views

Given that I in my workspace I have an android project MyAndroidProject and my tests project MyAndroidProjectTests directories how could I write a pre-commit git hook that will run the tests in the ...
racl101's user avatar
  • 4,120
1 vote
1 answer
2k views

I'm new to scripting and would like to understand how to print out the variables based on boolean logic. #!/bin/bash # set variables WEBAPPS_YES="Successfully synced webapps folder" WEBAPPS_NO="...
eekfonky's user avatar
  • 855

15 30 50 per page