![](/img/trans.png)
[英]How to bash pass command as an argument to function which run in sub shell?
[英]How to pass an integer as an argument in Shell function and retrieve it
我有一个这样的小功能-
#! /bin/sh
function hey() {
a=$1
echo $a
}
x=2
hey x
根据我的理解,它应该打印2
但它正在打印x
。 怎么解决呢?
用我的bash(不是sh)运行代码,它也会打印x。 但是如果我将最后一行更改为
hey $x
然后打印2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.