bash脚本退出代码解释
Exit Codes With Special Meanings
| Exit Code Number | Meaning | Example | Comments | 
|---|---|---|---|
| 1 | Catchall for general errors | let "var1 = 1/0" | Miscellaneous errors, such as "divide by zero" and other impermissible operations | 
| 2 | Misuse of shell builtins (according to Bash documentation) | empty_function() {} | Missing keyword or command, or permission problem (and diff return code on a failed binary file comparison). | 
| 126 | Command invoked cannot execute | /dev/null | Permission problem or command is not an executable | 
| 127 | "command not found" | illegal_command | Possible problem with $PATH or a typo | 
| 128 | Invalid argument to exit | exit 3.14159 | exit takes only integer args in the range 0 - 255 (see first footnote) | 
| 128+n | Fatal error signal "n" | kill -9 $PPID of script | $? returns 137 (128 + 9) | 
| 130 | Script terminated by Control-C | Ctl-C | Control-C is fatal error signal 2, (130 = 128 + 2, see above) | 
| 255* | Exit status out of range | exit -1 | exit takes only integer args in the range 0 - 255 | 
According to the above table, exit codes 1 - 2, 126 - 165, and 255 [1] have special meanings, and should therefore be avoided for user-specified exit parameters. Ending a script with exit 127 would certainly cause confusion when troubleshooting (is the error code a "command not found" or a user-defined one?). However, many scripts use an exit 1 as a general bailout-upon-error. Since exit code 1 signifies so many possible errors, it is not particularly useful in debugging.
bash脚本退出代码解释的更多相关文章
- 如何写出安全的、基本功能完善的Bash脚本
		
每个人或多或少总会碰到要使用并且自己完成编写一个最基础的Bash脚本的情况.真实情况是,没有人会说"哇哦,我喜欢写这些脚本".所以这也是为什么很少有人在写的时候专注在这些脚本上. ...
 - grep 查找bash脚本中的注释代码
		
出于安全性的考虑,不建议在bash脚本中注释掉不使用的代码.也就是说如果某段代码不使用了,那么应该删除掉,而不是简单地注释掉.假如你突然意识到这一点,而以前并没有遵从这个原则,现在需要找出脚本中的注释 ...
 - 实验楼-高级Bash脚本编程指南
		
实验1.Bash介绍与入门 1.简介:Bash是一个为GNU计划编写的Unix shell,它是许多Linux平台默认使用的shell shell是一个命令解释器,是介于操作系统内核与用户之间的一个绝 ...
 - 生产力工具:shell 与 Bash 脚本
		
生产力工具:shell 与 Bash 脚本 作者:吴甜甜 个人博客网站: wutiantian.github.io 注意:本文只是我个人总结的学习笔记,不适合0基础人士观看. 参考内容: 王顶老师 l ...
 - Bash脚本编程之脚本基础和bash配置文件
		
脚本基础 参考资料:Shell Scripts (Bash Reference Manual) 不严谨地说,编程语言根据代码运行的方式,可以分为两种方式: 编译运行:需要先将人类可识别的代码文件编译成 ...
 - Bash脚本编程学习笔记08:函数
		
官方资料:Shell Functions (Bash Reference Manual) 简介 正如我们在<Bash脚本编程学习笔记06:条件结构体>中最后所说的,我们应该把一些可能反复执 ...
 - Bash脚本15分钟进阶指导
		
首先声明这是网上摘来的.这里的技术技巧最初是来自谷歌的“Testing on the Toilet” (TOTT).这里是一个修订和扩增版本. 脚本安全 我的所有bash脚本都以下面几句为开场白: # ...
 - Bash脚本实现批量作业并行化
		
http://jerkwin.github.io/2013/12/14/Bash%E8%84%9A%E6%9C%AC%E5%AE%9E%E7%8E%B0%E6%89%B9%E9%87%8F%E4%BD ...
 - 一个很不错的bash脚本编写教程
		
转自 http://blog.chinaunix.net/uid-20328094-id-95121.html 一个很不错的bash脚本编写教程,至少没接触过BASH的也能看懂! 建立一个脚本 Lin ...
 
随机推荐
- kinect (oldest one) (libfreenect with py_kinect) on  linux ubuntu14.04 x64
			
freenect libs Where is the resource? Here :P : https://github.com/OpenKinect/libfreenect To make sur ...
 - iphone/ipad/iOS on Linux  Debian7/ubuntu12.04/linuxmint13/ubuntu14.04 compiling from source
			
The packages we need for ubuntu12.04 and its derived destros are: libimobiledevices, libplist, libus ...
 - mosquitto MQTT message broker on ubuntu/debian built from source
			
what is mosquitto? check this out! http://mosquitto.org what is MQTT? check this out. http://mqtt.or ...
 - MacOSX 下.app支持同时运行多个实例
			
在MacOSX下的.app是一个程序包(实际上是个目录),双击该目录时系统会根据包的目录结构启动相应的可执行程序..app的程序默认是单实例运行的,所以从.app启动的程序实例只有一个(可执行程序不受 ...
 - C# ASP.net 入门之简单通讯录
			
简单通讯录功能虽然简单,却包括了制作一个网站的基本功能!各个模块可以作为新手入门的参考. 简单通讯录实现功能:1.登录 2.注册 3.后台管理 4.前台登录显示 5.创建联系人 6.密码修改 代码下载 ...
 - Android 关于在Activity中监听ListView
			
Android 开发时,最常用的控件之一就是ListView了,而使用ListView的同时,必然需要对它设置监听器,常用的监听器有这么几个: 1. OnItemClickListener // 监听 ...
 - Cocos2dx使用网络图片
			
#ifndef __Demo__Connection__ #define __Demo__Connection__ #include <iostream> #include "c ...
 - Python json解析
			
#encoding: utf-8 ''' Author:Siukwan ''' import sys reload(sys) sys.setdefaultencoding('utf8') import ...
 - OpenH264
			
转自:http://blog.csdn.net/chinabinlang/article/details/41209053 目前最常用的264工程师x264: 最近有又有一个开源工程OpenH264, ...
 - websocket+前后端分离+https的nginx配置
			
后端服务路径: 172.168.0.2:8080 172.168.0.2:7080 前端目录(html + css + js): /root/apps/mzsg-web 1.修改 /etc/nginx ...