Timeline for How to pass an array as function argument?
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 1, 2023 at 9:51 | comment | added | oligofren | This does not handle arguments that are empty strings. It just expands the array as arguments and recreates it. | |
Feb 10, 2022 at 22:01 | comment | added | Manuel Jordan |
Is there a critical difference between #! /bin/bash and #!/bin/bash ? I have read many tutorials using the former - it works in peace. Now here the latter indicated how the correct syntax.
|
|
Aug 30, 2021 at 7:11 | comment | added | SenhorLucas | Shebang is spelled without the dash. | |
Jan 12, 2021 at 19:18 | comment | added | x-yuri |
In this particular case you can do for i; do ...; done to iterate over $@ . Also, this wasn't asked, but if you need to pass a couple of arrays, you probably want to pass by reference.
|
|
Mar 28, 2020 at 11:04 | comment | added | YoungFrog |
among the variants, there's copyFiles() { ... } without a function keyword. Added benefit : also valid in POSIX (unix.stackexchange.com/questions/73750/…)
|
|
Feb 25, 2020 at 20:04 | history | edited | kbenoit | CC BY-SA 4.0 |
Add spaces to the values passed.
|
May 10, 2017 at 16:34 | review | Suggested edits | |||
May 10, 2017 at 17:08 | |||||
Sep 15, 2015 at 11:16 | history | edited | A.B. | CC BY-SA 3.0 |
added 88 characters in body
|
Sep 15, 2015 at 11:14 | comment | added | A.B. |
Valid variants are copyFiles {…} and copyFiles(){…} and copyFiles() {…} , but not copyFiles{…} . Note the space in the variant without ()
|
|
Sep 15, 2015 at 11:11 | comment | added | Ahasanul Haque | thanks, but isn't function copyFiles{…} a correct syntax? Though i am a new bie i run some program successfully with the syntax. | |
Sep 15, 2015 at 11:09 | vote | accept | Ahasanul Haque | ||
Sep 15, 2015 at 9:29 | history | edited | A.B. | CC BY-SA 3.0 |
added 205 characters in body
|
Sep 15, 2015 at 9:24 | history | answered | A.B. | CC BY-SA 3.0 |