Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about bash function return values #20

Open
dxdxdt opened this issue Oct 30, 2021 · 0 comments
Open

Question about bash function return values #20

dxdxdt opened this issue Oct 30, 2021 · 0 comments

Comments

@dxdxdt
Copy link

dxdxdt commented Oct 30, 2021

I think that there are two types of return values of shell functions: the exit code and the standard output. The exit code of a function can be checked for errors and the standard output is usually used as values(call by ref).

if number_of_procs=$(nproc); then
# do something with number_of_procs
else
# handle error
fi

Now, let's say nproc is a shell function rather than the binary. How would you document \retval(the standard output - number of threads) and \exitcode(0 on success, 1 on error)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant