.profile bug?

In my .profile I have 3 lines that look something like this:

if [ sometest ]; then
do_something
fi

but if I change that to:

if [ sometest ]; then
#do_something
fi

I get an error that says “Unexpected ‘fi’ on line X”.

I do believe that it’s legal to have no executable statements inside of a
condition block.


Bill Caroselli – 1(530) 510-7292
Q-TPS Consulting
QTPS@EarthLink.net

Bill Caroselli <qtps@earthlink.net> wrote:

In my .profile I have 3 lines that look something like this:

if [ sometest ]; then
do_something
fi

but if I change that to:

if [ sometest ]; then
#do_something
fi

I get an error that says “Unexpected ‘fi’ on line X”.

I do believe that it’s legal to have no executable statements inside of a
condition block.

I don’t think so. I tried this on a few different versions of the
pdksh, and all of them rejected it with some sort of error.

I also looked at the ORA book on the Korn Shell, and it labels the
internals of the block as “statements”.

In the manual, it uses the term “list” for the internal:

if LIST then LIST [elif LIST then LIST]… [else LIST] fi

looking at this, LIST sure looks like a required rather than an
optional piece between the then and the fi. And, seems just as
manadatory as the LIST directly after the if.

-David

QNX Training Services
I do not answer technical questions by email.

Well I was about to come back and whine like a baby and say “But QNX4 let’s
me do it!”. But before I did I tried it. QNX4 doesn’t allow it either. Oh
well, bummer.

Anyway, this works:

if [ sometest ]; then
true ; #do_something
fi

Good call, Dave.


Bill Caroselli – 1(530) 510-7292
Q-TPS Consulting
QTPS@EarthLink.net


“David Gibbs” <dagibbs@qnx.com> wrote in message
news:9s9kf0$53r$1@nntp.qnx.com

Bill Caroselli <> qtps@earthlink.net> > wrote:
I do believe that it’s legal to have no executable statements inside of
a
condition block.

I don’t think so. I tried this on a few different versions of the
pdksh, and all of them rejected it with some sort of error.

I also looked at the ORA book on the Korn Shell, and it labels the
internals of the block as “statements”.

In the manual, it uses the term “list” for the internal:

if LIST then LIST [elif LIST then LIST]… [else LIST] fi

looking at this, LIST sure looks like a required rather than an
optional piece between the then and the fi. And, seems just as
manadatory as the LIST directly after the if.

-David

QNX Training Services
I do not answer technical questions by email.

“Operating System Tech Support” <os@qnx.com> wrote in message
news:9sbfqk$a2j$1@nntp.qnx.com

You can put in a null statement to mean nothing for a shell script

if [sometest]; then
;
fi

-Adam

Thank you. I actually changed it to"
if [ sometest ]; then
;#do_something
fi

This was just supposed to be a temporary little debug session. I’ve already
spent about 10 times longer on it then I anticipated.

But I must admit, it was an eye opener. I figured it was like C, that I
didn’t HAVE to do something inside the statement block. It just shows, you
learn something every day. Weather you want to or not.


Bill Caroselli – 1(530) 510-7292
Q-TPS Consulting
QTPS@EarthLink.net

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:9s9kf0$53r$1@nntp.qnx.com

Bill Caroselli <> qtps@earthlink.net> > wrote:
In my .profile I have 3 lines that look something like this:

if [ sometest ]; then
do_something
fi

but if I change that to:

if [ sometest ]; then
#do_something
fi

I get an error that says “Unexpected ‘fi’ on line X”.

I do believe that it’s legal to have no executable statements inside of
a
condition block.

I don’t think so. I tried this on a few different versions of the
pdksh, and all of them rejected it with some sort of error.

You can put in a null statement to mean nothing for a shell script

if [sometest]; then
;
fi

-Adam