2 мар. 2018 г. · Functions in Bash currently do not support user-named arguments. |
14 мая 2014 г. · Is there any easy way to pass (receive) named parameters to a shell script? For example, my_script -p_out '/some/path' -arg_1 '5' And inside my_script.sh ... |
1 апр. 2014 г. · In bash you can use ${!varname} to expand the variable referenced by the contents of another. Eg: $ var=hello $ foo () { echo "${!1}"; } $ foo var hello |
25 мая 2022 г. · Functions don't have named arguments in POSIX shell or Bash. Instead, the arguments show up in the positional parameters, $1 , $2 , etc. |
22 окт. 2015 г. · getArgs $* would pass the result of the split+glob operator applied to the list of positional parameters to getArgs, it doesn't make any sense. |
26 мар. 2019 г. · If you pass the name of a variable to function, use "${!1}" to get the value of the variable named in $1 , and plain "$1" to get the name. |
8 мар. 2023 г. · You'd use a nameref for that: writeToArray() { local -n writeToArray_name="$1" writeToArray_name[0]="does this work?" } Testing: |
29 авг. 2022 г. · I am new to shell and I was trying to write a custom function that takes regular arguments, as well as parse any flags provided. |
19 дек. 2016 г. · This article shows two different ways - shift and getopts (and discusses the advantages and disadvantages of the two approaches). |
9 мар. 2018 г. · The positional parameters of the caller's scope are not available in a function. You'd need the caller to pass them to the function one way or another. |
Novbeti > |
Axtarisha Qayit Anarim.Az Anarim.Az Sayt Rehberliyi ile Elaqe Saytdan Istifade Qaydalari Anarim.Az 2004-2023 |