我是unix shell脚本的新手.我试图用参数执行示例函数,但shell不会将第一个参数识别为第一个参数而是识别为第二个参数.
#!/bin/bash
func(){
echo "func"
if [ -z $1 ]
then echo "$1 received"
else echo "not received"
fi
}
func "hello"
Run Code Online (Sandbox Code Playgroud)
没有收到输出功能
应该给予的地方
func
hello received
Run Code Online (Sandbox Code Playgroud)