summaryrefslogtreecommitdiff
path: root/libc/elf/ldd.bash.in
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2013-10-18 21:33:25 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2013-10-18 21:33:25 +0000
commitfe2ed5aaa408e1ab996a9fe1595a05634208a79c (patch)
treee1027fbc9d8a4a8c33f8149b2b42e8cde89c74f6 /libc/elf/ldd.bash.in
parent571c782b982d888565e7d06bfc2f3d47582fe829 (diff)
downloadeglibc2-fe2ed5aaa408e1ab996a9fe1595a05634208a79c.tar.gz
Merge changes between r23946 and r24305 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@24306 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/elf/ldd.bash.in')
-rw-r--r--libc/elf/ldd.bash.in27
1 files changed, 13 insertions, 14 deletions
diff --git a/libc/elf/ldd.bash.in b/libc/elf/ldd.bash.in
index 73e35662d..c4a1a1513 100644
--- a/libc/elf/ldd.bash.in
+++ b/libc/elf/ldd.bash.in
@@ -44,7 +44,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
exit 0
;;
--h | --he | --hel | --help)
- printf $"Usage: ldd [OPTION]... FILE...
+ echo $"Usage: ldd [OPTION]... FILE...
--help print this help and exit
--version print version information and exit
-d, --data-relocs process data relocations
@@ -106,19 +106,18 @@ if test "$unused" = yes; then
add_env="$add_env LD_DEBUG=\"$LD_DEBUG${LD_DEBUG:+,}unused\""
fi
-# The following use of cat is needed to make ldd work in SELinux
-# environments where the executed program might not have permissions
-# to write to the console/tty. But only bash 3.x supports the pipefail
-# option, and we don't bother to handle the case for older bash versions.
-if x=`set -o` && test "$x" != "${x#*pipefail}" && set -o pipefail ; then
- try_trace() {
- eval $add_env '"$@"' | cat
- }
-else
- try_trace() {
- eval $add_env '"$@"'
- }
-fi
+# The following command substitution is needed to make ldd work in SELinux
+# environments where the RTLD might not have permission to write to the
+# terminal. The extra "x" character prevents the shell from trimming trailing
+# newlines from command substitution results. This function is defined as a
+# subshell compound list (using "(...)") to prevent parameter assignments from
+# affecting the calling shell execution environment.
+try_trace() (
+ output=$(eval $add_env '"$@"' 2>&1; rc=$?; printf 'x'; exit $rc)
+ rc=$?
+ printf '%s' "${output%x}"
+ return $rc
+)
case $# in
0)