Shell组件的返回码,0为成功,其他为失败.

Shell的返回码

Shell每一行脚本都有执行返回码,返回码0为成功,其他为失败.

Shell脚本的返回码0为成功,其他为失败

可使用exit命令来设置返回码。函数可使用return设置可使用echo $? 来查看上一行命令的返回码,可使用exit命令来设置返回码。

exit函数只能使用0~255之间的值. 如果传-1的话接收到的就是255(unsigned值)。因为历史上子进程返回的是16bit的int,高8位就是程序退出的值(exit返回码)

典型退出状态码及其含义

退出状态码

含义

0

命令运行成功

1

通知未知错误

2

误用shell命令

126

命令不可执行

127

没有找到命令

128

无效退出参数

128+x

linux信号x的严重错误

130

命令通过Ctrl+C终止

255

退出状态码越界

在Linux的内建Shell命令中, 很多都会遵守一个退出状态码的约定, 具体的值对应的意思:

Exit Code NumberMeaningExampleComments
1Catchall for general errorslet “var1 = 1/0″Miscellaneous errors, such as ”divide by zero” and other impermissible operations
2Misuse of shell builtins (according to Bash documentation)empty_function() {}Seldom seen, usually defaults to exit code 1
126Command invoked cannot execute Permission problem or command is not an executable
127“command not found”illegal_commandPossible problem with $PATH or a typo
128Invalid argument to exitexit 3.14159exit takes only integer args in the range 0 – 255 (see first footnote)
128+nFatal error signal ”n”kill -9 $PPID of script$? returns 137 (128 + 9)
130Script terminated by Control-C Control-C is fatal error signal 2, (130 = 128 + 2, see above)
255*Exit status out of rangeexit -1exit takes only integer args in the range 0 – 255

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Vue.js中使用ElementUI实现文件上传功能,可以按照以下步骤进行操作: 1. 安装ElementUI和axios: ``` npm install element-ui axios ``` 2. 在Vue项目中引入ElementUI和axios: ```javascript import Vue from 'vue' import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' import axios from 'axios' Vue.use(ElementUI) Vue.prototype.$axios = axios ``` 3. 在组件中添加文件上传组件: ```html <template> <div> <el-upload class="upload-demo" action="/upload" :on-success="handleSuccess" :before-upload="beforeUpload" :file-list="fileList" :auto-upload="false"> <el-button size="small" type="primary">点击上传</el-button> <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> </el-upload> </div> </template> ``` 在`el-upload`组件中,我们指定了上传文件的地址和一些属性,例如`before-upload`和`on-success`。在`before-upload`中,我们可以对上传的文件进行一些校验,例如文件类型和大小;在`on-success`中,我们可以处理上传成功后的回调。 4. 在组件的`data`选项中添加文件列表: ```javascript export default { data() { return { fileList: [] } }, methods: { handleSuccess(response, file, fileList) { // 处理上传成功后的回调 }, beforeUpload(file) { // 对上传的文件进行校验 } } } ``` 5. 在`beforeUpload`方法中,我们可以通过`return false`来阻止上传,或者通过`return true`来允许上传。在这个方法中,我们还可以使用ElementUI的`Message`组件来提示用户上传文件的限制条件: ```javascript beforeUpload(file) { const isJPG = file.type === 'image/jpeg' || file.type === 'image/png' const isLt2M = file.size / 1024 / 1024 < 2 if (!isJPG) { this.$message.error('上传图片只能是 JPG/PNG 格式!') } if (!isLt2M) { this.$message.error('上传图片大小不能超过 2MB!') } return isJPG && isLt2M } ``` 这样,我们就可以在Vue.js中使用ElementUI实现文件上传功能了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值