问题:
This question already has answers here :
这个问题已经在这里有了答案 :
Closed 13 days ago .
13天前关闭。
Let's say I have defined a function abc()
that will handle the logic related to analyzing the arguments passed to my script. 假设我已经定义了一个function abc()
,它将处理与分析传递给脚本的参数有关的逻辑。
How can I pass all arguments my bash script has received to it? 如何将bash脚本收到的所有参数传递给它? The number of params is variable, so I can't just hardcode the arguments passed like this: 参数的数量是可变的,所以我不能仅仅对这样传递的参数进行硬编码:
abc $1 $2 $3 $4
Edit . 编辑 。 Better yet, is there any way for my function to have access to the script arguments' variables? 更好的是,我的函数是否可以访问脚本参数的变量?
解决方案:
参考一: https://stackoom.com/question/FzVJ/如何将传递给我的bash脚本的所有参数传递给我的函数-重复参考二: https://oldbug.net/q/FzVJ/How-to-pass-all-arguments-passed-to-my-bash-script-to-a-function-of-mine-duplicate
来源:oschina
链接:https://my.oschina.net/stackoom/blog/4282283