Skip to contentSkip to conversation

Command parsing problem and tracefile

DISCUSSION Richard H Lee 2 participants 4 messages Jun 8, 2012

lore
Share & tools
lore
#0 lore raw

Dash mailing list,

I have one issue with dash and one question regarding debugging.

First up, when I run a configure script and it hits the following line:
if $_pkg_config --exists --print-errors $all_libav_libs ; then

with $_pkg_config being 'pkg-config --static', dash throws the following error:
./configure: 6012: ./configure: pkg-config --static: not found

I've tried adding brackets around the condition, but with no avail. Is there anything wrong with the syntax.

Secondly, I decided to delve deeper with gdb and I can see dash calling:
find_command('pkg-config --static')

I would like to get some more info as to what in going on. IIRC, I saw in show.c, there was some sort for tracefile that dash to dump to. How do I enable this?

Richard

#1 lore raw

Hi Richard,

Quoted 6 lines · Richard H Lee

First up, when I run a configure script and it hits the following line:
if $_pkg_config --exists --print-errors $all_libav_libs ; then

with $_pkg_config being 'pkg-config --static', dash throws the following error:
./configure: 6012: ./configure: pkg-config --static: not found

Thanks for writing. Who is setting _pkg_config to 'pkg-config --static', what are they trying to do, and can it be done another way?

This doesn't look like a dash-specific phenomenon. I get the same result with

	$ "pkg-config --static" foo bar
	dash: 1: pkg-config --static: not found

which looks right to me. (You can test with 'CONFIG_SHELL=/bin/ksh ksh ./configure'.)

[...]

Quoted 3 lines

I would like to get some more info as to what in going on. IIRC, I saw in show.c, there was some sort for tracefile that dash to dump to. How do I enable this?

"dash -o debug" after a compile with DEBUG enabled. Though "dash -x" tends to be more helpful if you are debugging a shell script rather than trying to find a bug in dash itself.

Hope that helps,
Jonathan

#2 lore raw

Hi Jonathan,

Quoted 2 lines · Jonathan Nieder

Thanks for writing. Who is setting _pkg_config to 'pkg-config --static', what are they trying to do, and can it be done another way?

I'm compiling mplayer2. I'm basically running ./configure --enable-static . I assume without the --enable-static flag the configure script sets _pkg_config to just 'pkg-config' .

I want to try and statically compile it as there is a bug with one of the libraries. So I'm planning to compile a modified libav library first and then compile mplayer2 statically against them. I guess I could do it dynamically, but then I would have modified libraries floating around my system.

Quoted 8 lines

This doesn't look like a dash-specific phenomenon. I get the same result with

	$ "pkg-config --static" foo bar
	dash: 1: pkg-config --static: not found

which looks right to me. (You can test with 'CONFIG_SHELL=/bin/ksh ksh ./configure'.)

[Note: I don't think CONFIG_SHELL is used here as the configure script is not autotools generated.]

It didn't occur to me to try other shells. I get the same error with bash. It makes me wonder why it occurs on three different shells? Is this defined behaviour? Or they just happen to share the same parsing code/algorithm.

I also tried running the following script:
<<EOF
#!/bin/sh
_pkg_config='pkg-config --static'
if $_pkg_config --exists --print-errors libavutil ; then
echo success
fi
EOF

Which does print out 'success' (replace libavutil with any other pkg-config library you have installed). I get the feeling, some sort of flag was set that changes the parsing behaviour in the configure script.

Quoted 7 lines
Quoted 3 lines

I would like to get some more info as to what in going on. IIRC, I saw in show.c, there was some sort for tracefile that dash to dump to. How do I enable this?

"dash -o debug" after a compile with DEBUG enabled. Though "dash -x" tends to be more helpful if you are debugging a shell script rather than trying to find a bug in dash itself.

From shell.h:
define DEBUG=1 to compile in debugging ('set -o debug' to turn on)
define DEBUG=2 to compile in and turn on debugging.
When debugging is on, debugging info will be written to ./trace and a quit signal will generate a core dump.

This is exactly what I was looking for.

As to compiling with DEBUG enabled, how would I do this?
I couldn't see any reference in dash's ./configure --help (nor any clear reference in the configure file itself).

Thanks,

Richard

#3 lore raw
Quoted 2 lines · Richard H Lee

It didn't occur to me to try other shells. I get the same error with bash. It makes me wonder why it occurs on three different shells?

Yes, that's because it's a bug in the configure script, not dash.

Your best bet is to contact whoever provided that configure script and explain that --enable-static is not working for you. The specification that defines POSIX shell script syntax can be found at
<http://unix.org/2008edition/>.

Good luck,
Jonathan