[PATCH v2][BZ #832][BZ #3266] Make ldd try_trace more robust and portable

Mike Frysinger vapier@gentoo.org
Tue Sep 10 21:02:00 GMT 2013


On Saturday 07 September 2013 11:45:45 Patrick "P. J." McDermott wrote:
> +# The following command substitution is needed to make ldd work in
> +# SELinux environments where the executed program might not have
> +# permissions to write to the console/tty.  The extra "x" character
> +# prevents the shell from trimming trailing newlines from command
> +# substitution results.
> +try_trace() {
> +  output=$(eval $add_env '"$@"'; rc=$?; printf 'x'; exit $rc)
> +  rc=$?
> +  printf '%s' "${output%x}"
> +  return $rc
> +}

not really a new issue, but doesn't this also need to handle stderr ?

simply adding 2>&1 for the eval statement seems sufficient

i dislike the missing `local` decls for output and rc.  but those aren't 
exactly specified in POSIX (even if every reasonable shell supports it).  maybe 
do a double sub-shell instead ?

try_trace() {
	(
	output=$(.....)
	rc=$?
	printf ....
	exit $rc
	)
}
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20130910/c719ecde/attachment.sig>


More information about the Libc-alpha mailing list