You are not logged in.
I'm examining some PKGBUILD's to hopefully learn to make my own. And I've seen this line
make || return 1. I understand that's where the code is compiled according to the makefile, but why the
|| return 1I know return 1 just returns success, but why would you want that? and what does the || do?
"Oh, they have the internet on computers now."
Offline
&& and || check a previous command for successful completion or failure respectively (more exactly, a zero or nonzero exit status)
i.e.
cd $HOME && rm ./*
will only do the rm if the cd completes successfully
or
make || return 1
will only return (with a 1 exit status) if the make command fails. this is a good way to break out of a script/function/loop if something fails
//github/
Offline
If the build function returns 1 then it is considered an error (most applications return 0 upon success and something else when there is an error).
"make || return 1" could be read as "Try to compile the code. If there is an error, exit the build function and report an error, otherwise continue.".
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
You can try to understand it this way;
&& looks like the logical AND
|| looks like the logical OR
So, in that case - either do command1 with success OR do command2.
Last edited by moljac024 (2009-06-09 00:17:01)
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
In the land of shell scripting, 0 is success and anything else is failure.
Also, you might find this informative: http://en.wikipedia.org/wiki/Short-circuit_evaluation
Last edited by Peasantoid (2009-06-09 00:20:37)
Offline