相关疑难解决方法(0)

为什么要在Bash中避免使用eval,我应该使用什么呢?

我一次又一次地看到Bash在Stack Overflow上使用eval的答案,并且答案得到了抨击,双关语是为了使用这种"邪恶"结构.为什么eval这么邪恶?

如果eval不能安全使用,我应该使用什么呢?

unix linux bash eval

94
推荐指数
3
解决办法
6万
查看次数

如何使用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万
查看次数

标签 统计

bash ×2

argv ×1

command-line-arguments ×1

eval ×1

linux ×1

unix ×1