相关疑难解决方法(0)

如何使用Bash访问函数内的命令行参数?

我正在尝试在bash中编写一个函数来访问脚本命令行参数,但是它们被替换为函数的位置参数.如果函数没有显式传递,是否有任何方法可以访问命令行参数?

# Demo function
function stuff {
  echo $0 $*
}

# Echo's the name of the script, but no command line arguments
stuff

# Echo's everything I want, but trying to avoid
stuff $*
Run Code Online (Sandbox Code Playgroud)

bash argv command-line-arguments

89
推荐指数
5
解决办法
13万
查看次数

标签 统计

argv ×1

bash ×1

command-line-arguments ×1