Re: [PATCH]: Makefile

From: Grant Erickson (grant@borg.umn.edu)
Date: Thu Aug 31 2000 - 11:09:10 EST


On Thu, 31 Aug 2000, Michael Elizabeth Chastain wrote:
> What problem are you trying to solve?

The fact that if $$BASH is not defined, Korn shell, Bourne shell, Bourne
Again Shell, C Shell and Tenon C Shell, all hiccup on the "else if". In
addition, there's an extra 'fi' at the end. This is definitely not C shell
syntax nor is it proper Bourne shell syntax. Check 'man ksh' or 'man
bash'.

> The shell invoked by $(shell ...) could be anything, especially in a
> cross build.

Precisely my problem. However, if you are writing Bourne shell syntax,
then you CANNOT assume that $(shell ...) could be anything. In fact, if
shell is not defined, then 'SHELL' defaults to /bin/sh. See 'info make'.

A little demonstration:

% uname -a
SunOS marathon 5.7 Generic_106541-07 sun4u sparc

% cat test
if [ -x "$BASH" ]; then
        echo $BASH
else if [ -x /bin/bash ]; then
        echo /bin/bash
else
        echo sh
fi

% /bin/sh test
test: syntax error at line 8: `end of file' unexpected

% /bin/ksh test
test: syntax error at line 3 : `else' unmatched

% /bin/csh test
Missing ]

% /usr/local/bin/tcsh test
if: Expression Syntax.

% /usr/gnu/bin/bash test
test: line 8: syntax error: unexpected end of file

Now change "else if" to "elif":

% cat test
if [ -x "$BASH" ]; then
        echo $BASH
elif [ -x /bin/bash ]; then
        echo /bin/bash
else
        echo sh
fi

% /bin/sh test
/usr/gnu/bin/bash

% /bin/ksh test
/usr/gnu/bin/bash

% /bin/csh test
Missing ]

% /usr/local/bin/tcsh test
if: Expression Syntax.

% /usr/gnu/bin/bash test
/usr/gnu/bin/bash

Everything works as expected.

> That's why we are looking for bash explicitly.

Correct. In situations where $(CONFIG_SHELL) is used in the Makefile or
Rules.make, the syntax following is definitely bash-specific.

> So, what is the benefit of using a new keyword 'elif' here?

Because it's proper shell syntax; whereas, 'else if' is not.

Regards,

Grant Erickson

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:27 EST