Conditional execution using ifneq

Conditional execution can also be done using ifneq which is the opposite of ifeq.

The syntax of ifneq is

ifneq(,) returns true when and are not equal. If and are equal it jumps to the else statement.

Using the above logic, the example used in the post "Conditional execution using ifeq" can be re written using ifneq as below.

Thus ifneq checks if the current user is not root, which if true then sets the target to $(pf)_1, else it sets it to $(pf)_2.

If we execute the make command as root we will get the following output

If we do the same as any other user other than root, we will get the following output

No comments:

Post a Comment

Follow by Email