ksh获取分配中的退出状态 [英] ksh get exit status in assignment

查看:59
本文介绍了ksh获取分配中的退出状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道执行分配的命令的退出状态.

I need to know the exit status of command that do assignment.

export VALUE=`My_Get_Value 10`

我需要知道My_Get_Value脚本的退出状态.

I need to know the exit status of My_Get_Value script.

$?中,我具有分配状态.

In the $? I have the status of assignment itself.

我在KSH v93中需要它

I need it in KSH v93

推荐答案

export VALUE=$(My_Get_Value 10)不是赋值语句;它是赋值语句.它是对export命令的调用,该命令接受 look 像赋值语句一样的参数.最简单的解决方法是将分配与呼叫export分开.

export VALUE=$(My_Get_Value 10) is not an assignment statement; it is a call to the export command, which takes arguments that look like assignment statements. The easiest fix is to separate the assignment from the call to export.

VALUE=$(My_Get_Value 10)
mgv_exit=$?
export VALUE

在赋值之前或之后调用export都没关系(只要您在赋值和保存$?的值之间不调用它),因为export将属性设置为名称 VALUE,而不是名为VALUE的参数的值.以下是相同的:

It doesn't matter if you call export before or after the assignment (as long as you don't call it between the assignment and saving the value of $?), since export sets an attribute on the name VALUE, not the value of the parameter named VALUE. The following is identical:

export VALUE
VALUE=$(My_Get_Value 10)
mgv_exit=$?

这篇关于ksh获取分配中的退出状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆