Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 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? Commented Jan 20, 2018 at 16:39
  • 1
    @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. Commented Jan 20, 2018 at 16:48
  • 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. Commented Jan 20, 2018 at 17:20
  • 1
    @Danloc btw, unix.stackexchange.com/questions/313256/… Commented Jan 20, 2018 at 17:28
  • 1
    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. Commented Jan 20, 2018 at 18:21