ls bug in /bin/sh for QNX 6.2.0

I am finding a problem building open source packages under QNX
6.2.0. A lot of configure scripts fail due to a bug in ls. The following
script illustrates the problem:

#!/bin/sh
set X ls -Lt ./configure conftestfile
echo $*

gives the following output in the MySQL source directory:

X conftestfile ./configure ./configure.in ./configure.log

It appears that the shell is adding an unrequested wildcard. On Linux,
I get the following (expected) output.

X conftestfile ./configure

There is not an alias defined for ls either on QNX or Linux when I run
the script.

If I type:

ls -Lt ./configure conftestfile

from the command line, I get what I expect on both Linux and QNX:

conftestfile ./configure

Any ideas what is going on? This is very annoying since it makes
building a lot of third party open source packages impossible.

…Stephen

Stephen Rasku <spr@shaw.ca> wrote:

I am finding a problem building open source packages under QNX
6.2.0. A lot of configure scripts fail due to a bug in ls. The following
script illustrates the problem:

#!/bin/sh
set X ls -Lt ./configure conftestfile

have you tried the fullpath of /bin/ls ?
set X /bin/ls -Lt ./configure conftestfile
I’ve bitten many items by the shell alias, your ‘ls’ may be
an alias of something else.
That’s why I usually use fullpath of the commands in my shell
script. You don’t have control of the users who will be running
your script. They could have a weird shell alias …

Maybe there is a way to unalias everything at the top of your script?

Frank

Stephen Rasku <spr@shaw.ca> wrote:

I am finding a problem building open source packages under QNX
6.2.0. A lot of configure scripts fail due to a bug in ls. The following
script illustrates the problem:

#!/bin/sh
set X ls -Lt ./configure conftestfile
echo $*

Are you using bash as your main shell? If so, even if your script
is #!/bin/sh, bash will start a new instance of itself and run your
…bashrc. Once I removed this line from my ~/.bashrc…

alias ls=“ls -CF”

…the problem went away. The -F was causing the shell to put in a * at
the end of the configure script (executable), which got exapnded when you
did the echo. Why it works when you change /bin/sh to /usr/bin/bash
is another bash-ism, probably having to do it behaving differently if
the shell script is being run as a bash script.

chris


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

In article <c08vio$75r$1@nntp.qnx.com>, Chris McKillop wrote:

Are you using bash as your main shell? If so, even if your script
is #!/bin/sh, bash will start a new instance of itself and run your
.bashrc. Once I removed this line from my ~/.bashrc…

alias ls=“ls -CF”

…the problem went away. The -F was causing the shell to put in a * at
the end of the configure script (executable), which got exapnded when you
did the echo. Why it works when you change /bin/sh to /usr/bin/bash
is another bash-ism, probably having to do it behaving differently if
the shell script is being run as a bash script.

I am using /bin/sh as my main shell. This is a symlink to ksh.
It appears that I am having a similar problem as you were. I have:

alias ls=“ls -cF”

declared in my .kshrc. However, I was confused because, even when I
unaliased it from the command line, I would still get the same problem.
However, when I commented it out in my .kshrc, it would work properly.
It appears that the script is reading the .kshrc directly.

Thanks to all who replied.

…Stephen

declared in my .kshrc. However, I was confused because, even when I
unaliased it from the command line, I would still get the same problem.
However, when I commented it out in my .kshrc, it would work properly.
It appears that the script is reading the .kshrc directly.

It’s because when you run a script a new shell instance is invoked,
which causes those aliases to be setup. You should be able to add
them to your .profile instead and it won’t happen.

I tend to put them in my .bash_profile these days to avoid this and
other “ls” failures with the GNU Auto* tools.

chris


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/