delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/11/09/12:20:23

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: Workaround for silent linkage errors
Date: Fri, 9 Nov 2007 17:15:43 -0000
Message-ID: <2D9E96311DCA4C48BF185EA6928BC7BB02BA7757@asc-mail.int.ascribe.com>
From: "Phil Betts" <Phil DOT Betts AT ascribe DOT com>
To: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

------_=_NextPart_001_01C822F3.F0A31595
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

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=20
the variable read-only so that should a user want to override it,=20
they'd have to take extra steps and in doing so would learn why it=20
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=20
functions (if set -E is used) and sourced scripts, but it has the=20
disadvantage of printing the message twice if it was the last command=20
in the script which failed - once as the error is trapped within the=20
script, and once as the return status of the script is detected.

Another potential problem with the second method is that scripts=20
often trap errors themselves, and if such a script were sourced, it=20
would leave the trap handler changed on exit, so this mechanism is=20
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=20
is to ensure that it works (or at least does not cause other errors)
when using shells other than bash.

Phil


------_=_NextPart_001_01C822F3.F0A31595
Content-Type: application/octet-stream;
	name="dllcheck.sh"
Content-Transfer-Encoding: base64
Content-Description: dllcheck.sh
Content-Disposition: attachment;
	filename="dllcheck.sh"

IyBDb3B5cmlnaHQgKEMpIDIwMDcgUGhpbCBCZXR0cwojIFRoaXMgZmlsZSBp
cyBmcmVlIHNvZnR3YXJlOyBJIGdpdmUgdW5saW1pdGVkIHBlcm1pc3Npb24g
dG8gY29weSBhbmQvb3IKIyBkaXN0cmlidXRlIGl0LCB3aXRoIG9yIHdpdGhv
dXQgbW9kaWZpY2F0aW9ucywgYXMgbG9uZyBhcyB0aGlzIG5vdGljZSBpcwoj
IHByZXNlcnZlZC4KCiMgVGhpcyBmaWxlIGlzIHRvIGhlbHAgdGhlIGRldGVj
dGlvbiBhbmQgcmVwb3J0aW5nIG9mIGVycm9ycyBjYXVzZWQgYnkgbWlzc2lu
ZwojIERMTHMgaW4gY3lnd2luLiAgSW4gb3JkZXIgdG8gcHJldmVudCBub24t
aW50ZXJhY3RpdmUgc2NyaXB0cyBkaXNwbGF5aW5nIGRpYWxvZwojIGJveGVz
IHdoZW4gYW4gZXJyb3IgaXMgZGV0ZWN0ZWQsIGN5Z3dpbiBwcm9ncmFtcyBk
aXNhYmxlIHRoZSBkaWFsb2cgYm94LiAgVGhpcwojIGhhcyB0a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gdGhlIG1pc3NpbmcgZmlsZSIKZmkKIyBCZWZvcmUgY2hhbmdpbmcgUFJP
TVBUX0NPTU1BTkQsIHBsZWFzZSByZWFkIC9ldGMvcHJvZmlsZS5kL2RsbGNo
ZWNrLnNoJwoKZWxzZQoKdHJhcCAnICAgICAgICAgICAgICAgICAgICAgICAg
IAppZiBbICQ/ID0gNTMgXTt0aGVuCiBlY2hvICJNaXNzaW5nIERMTC4iCiBl
Y2hvICJSdW4gY3lnY2hlY2sgb24gdGhlIGV4ZWN1dGFibGUgdG8gaWRlbnRp
ZnkgdGhlIG1pc3NpbmcgZmlsZSIKIGVjaG8gIlRoZW4gdXNlIHRoZSBjeWd3
aW4gc2V0dXAgcGFja2FnZSBzZWFyY2ggYXQ6IgogZWNobyAiICBodHRwOi8v
Y3lnd2luLmNvbS9wYWNrYWdlcy8iCiBlY2hvICJ0byBpZGVudGlmeSB3aGlj
aCBwYWNrYWdlIGNvbnRhaW5zIHRoZSBtaXNzaW5nIGZpbGUiCiBlY2hvICJS
dW4gY3lnY2hlY2sgb24gdGhlIGV4ZWN1dGFibGUgdG8gaWRlbnRpZnkgdGhl
IG1pc3NpbmcgZmlsZSIKZmknIEVSUgoKZmkK


------_=_NextPart_001_01C822F3.F0A31595
Content-Type: text/plain; charset=us-ascii

--
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/
------_=_NextPart_001_01C822F3.F0A31595--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019