[PATCH 1/2] ldd: Make try_trace more robust and portable

Dmitry V. Levin ldv@altlinux.org
Tue Nov 27 00:21:00 GMT 2012


On Thu, Nov 22, 2012 at 10:41:10PM -0500, P. J. McDermott wrote:
[...]
> +try_trace() {
> +  output=$(eval $add_env '"$@"' && printf 'x') && printf '%s' "${output%x}"

If the trace command would fail somewhere in the middle, its output will
be lost.  What about this variant?

try_trace() {
  local output rc
  output=$(eval $add_env '"$@"'; rc=$?; printf 'x'; exit $rc)
  rc=$?
  printf '%s' "${output%x}"
  return $rc
}


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20121127/c8fda409/attachment.sig>


More information about the Libc-alpha mailing list