Timeline for Shell script with function and parameter as Variables
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 8, 2019 at 8:46 | vote | accept | Danloc | ||
| Jan 8, 2019 at 8:50 | |||||
| Jan 20, 2018 at 18:21 | comment | added | Sergiy Kolodyazhnyy |
As tomasz pointed out, there's something called main function. Define all functions first, including main() function. Particular order of declarations is irrelevant there. What's important is that you declare everything first, then call main at the end of script , i.e. make last line main "$@" . From there you can safely call other functions.
|
|
| Jan 20, 2018 at 17:28 | comment | added | user147505 | @Danloc btw, unix.stackexchange.com/questions/313256/… | |
| Jan 20, 2018 at 17:21 | comment | added | user147505 | @Danloc That shouldn't change anything. Just a matter of layout, so to say. | |
| Jan 20, 2018 at 17:20 | comment | added | Danloc | Yea that is possible and maybe i have to do it like that. The reason why why i want do do it not like that, is because my programm is a Dialog menu programm. And so it runs in a permanent while true; loop. So it would be more beautiful, if every dialog can call any other dialog o every time For your solution i have to add more functions at the end of the programm, where the essential function calls go through. | |
| Jan 20, 2018 at 16:48 | comment | added | user147505 |
@Danloc You can write the whole lot in functions and then at the end of the script pack the call structure in the highest level function. And at the very end of the script call that function. This way all the functions are called after their definitions. And traditionally the main function is called... main.
|
|
| Jan 20, 2018 at 16:39 | comment | added | Danloc | That could be a problem for me. My programm does not have only one function and they are called from other functions in if clauses. So i can't be sure, that function1 is declared before function2 (who call function1). Is it possible to do like this? | |
| Jan 20, 2018 at 16:27 | history | answered | user147505 | CC BY-SA 3.0 |