如何通过传递给我的bash脚本我的一个功能,所有参数?

问题描述:

比方说,我已经定义的函数ABC()将处理所有analising传递给我的脚本的参数相关的逻辑。

Let's say I have defined a function abc() that will handle all the logic related to analising the arguments passed to my script.

我如何通过我的bash脚本已收到它的所有论据?则params的数量是可变的,所以我不能只是很难code通过这样的参数:

How can I pass all arguments my bash script has received to it? 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?

忌讳:当使用 $ @ ,你应该(几乎)总是把它放在双引号为了避免争论misparsing带空格:

Pet peeve: when using $@, you should (almost) always put it in double-quotes to avoid misparsing of argument with spaces in them:

abc "$@"