Bug 832 - ldd contains a bashism
Summary: ldd contains a bashism
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: admin (show other bugs)
Version: 2.3.4
: P2 normal
Target Milestone: ---
Assignee: Roland McGrath
URL: https://sourceware.org/ml/libc-alpha/...
Keywords:
: 807 3266 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-04-07 09:34 UTC by Han Boetes
Modified: 2023-10-28 17:27 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Han Boetes 2005-04-07 09:34:03 UTC
This patch makes ldd work with any shell.

Ash doesn't continue after a set -o blah. The used method correctly identifies
bash 3 and higher.

Patch is tested with bash, zsh, ash and pdksh.

--- ldd.orig    2005-03-29 12:35:17.820676992 +0200
+++ ldd 2005-03-29 12:34:36.324985296 +0200
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 # Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
@@ -116,10 +116,12 @@
 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 set -o pipefail 2> /dev/null; then
+# 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 [ "${BASH_VERSION%%.*}" -ge 3 ]; then
+  set -o pipefail
   try_trace() {
     eval $add_env '"$@"' | cat
   }
Comment 1 Han Boetes 2005-04-07 09:41:36 UTC
*** Bug 807 has been marked as a duplicate of this bug. ***
Comment 2 Ulrich Drepper 2005-09-25 18:29:51 UTC
ldd is written for bash.  Live with it.
Comment 3 Dmitry V. Levin 2005-09-25 19:27:41 UTC
If ash stops after "set -o foo", it should be fixed.
Please report it to ash maintainers.
Comment 4 Han Boetes 2005-09-26 00:24:00 UTC
No: There is nothing wrong with ash, this is POSIX behaviour.
http://www.opengroup.org/onlinepubs/007908799/xcu/chap2.html#tag_001_008_001

There is something wrong with bash. This is a typical case of embrace and extend
of the guy who has written bash,  and so far all developers have applied my
patches that remove bashisms. I don't care if people write them, mistakes are
made everywhere but I'm really appalled by your Microsoft-like responses.
Especially since you don't loose any functionality if you apply my patch and you
are forced to use bash if you don't.
Comment 5 P. J. McDermott 2013-09-07 15:44:13 UTC
Reopening, with a patch on the way to the mailing list.
Comment 6 Mike Frysinger 2013-10-14 06:01:01 UTC
*** Bug 3266 has been marked as a duplicate of this bug. ***
Comment 7 Mike Frysinger 2013-10-14 06:02:28 UTC
should be fixed for glibc-2.19