Defining a function/procedure in Linux BASH is quite similar to other high-level languages.
functionName() { # content goes here }
However, passing parameters inside the function is somehow different, which is quite shell-style.
functionName() { # the first parameter is $1 # the second parameter is $2 # and so on. $0 is the script name }
If you want to define local variables that has the limited local scope, use the keyword local. Otherwise the vars defined will be accessed outside the function. This is somehow different than Python and PHP that you have to define global in order to access global variables otherwise the vars will be treated as local.
Happy scripting!
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
213 wordsloading...
Last Post: Quick Improvements on your TFileStream Access in Delphi
Next Post: Tools on Linux WINE