Home » Questions » Computers [ Ask a new question ]

What is wrong in the Bash script about parameters and Wget?

What is wrong in the Bash script about parameters and Wget?

Runnning the command gives

Asked by: Guest | Views: 194
Total answers/comments: 1
Guest [Entry]

"If you are executing this function from a shell prompt, the exit command is telling the shell to exit rather than the function. You should probably use return instead.

You can use a return value with return and test for that in the script that calls the function and use the exit there to exit the script (or not depending on the return value).

$ testfunc(){ return ${1:-0}; }
$ testfunc
$ echo $?
0
$ testfunc 0
$ echo $?
0
$ testfunc 1
$ echo $?
1"