This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Workaround for silent linkage errors


We seem to be getting a lot of messages along the lines of
"I ran xyz and it did nothing."  The typical response is something
like "if you echo $? it is probably 53 which indicates a missing
DLL."  This usually gives rise to a further email asking where
to get the missing DLL.

Attached is a short script which should provide a workaround for
the problem and hopefully reduce the mailing list traffic.

It is designed to be installed in /etc/profile.d and uses one of
two methods:

1) Use $PROMPT_COMMAND

We can use the PROMPT_COMMAND envvar to do the checking for us.

Although I use it myself, I imagine $PROMPT_COMMAND is a little-
used bash feature, so very few users would override this in their
own rc file, and will therefore get to see the message.  I have made 
the variable read-only so that should a user want to override it, 
they'd have to take extra steps and in doing so would learn why it 
is set up that way.  The definition of $PROMPT_COMMAND includes a
comment, so that users echoing $PROMPT_COMMAND will be instructed
to refer to /etc/profile.d/dllcheck.sh.

It's by no means a perfect solution, because the error is only
detected if the last command executed before the prompt failed.

Most of the reported problems were related to running a single
command, and not a command within a script, so this method should
be fine for the majority of cases.

2) Trap the error

This might be considered a better solution, as it also works inside 
functions (if set -E is used) and sourced scripts, but it has the 
disadvantage of printing the message twice if it was the last command 
in the script which failed - once as the error is trapped within the 
script, and once as the return status of the script is detected.

Another potential problem with the second method is that scripts 
often trap errors themselves, and if such a script were sourced, it 
would leave the trap handler changed on exit, so this mechanism is 
more prone to being defeated.

The file contains instructions on how to switch to the second method.

I've lifted the copyright message from Eric Blake's 00bash.sh script,
but essentially you're free to do whatever you like with it.  I've
only tested it under bash, so one modification you may wish to make 
is to ensure that it works (or at least does not cause other errors)
when using shells other than bash.

Phil

Attachment: dllcheck.sh
Description: dllcheck.sh

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]