- Package:
- resolvconf
- Source:
- resolvconf
- Submitter:
- Stefan Monnier
- Date:
- 2011-09-23 12:27:48 UTC
- Severity:
- wishlist
/sbin/resolvconf requires bash. 2 problems with that: 1 - the resolvconf package can be installed without installing bash 2 - that makes it unusable on a system where you use dash rather than bash
tags 519364 +patch
thanks
BTW, the patch below might help take care of the dependency.
Stefan
--- /sbin/resolvconf 2006-08-09 09:36:43.000000000 -0400
+++ /tmp/monnier/resolvconf 2009-03-11 22:56:26.031905443 -0400
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Need bash because of use of ${FOO/bar}
#
# Licensed under the GNU GPL. See /usr/share/doc/resolvconf/copyright.
@@ -41,11 +41,13 @@
report_iface_err() {
report_err "$* not allowed in interface record name"
}
- [ "${IFACE/\/}" = "$IFACE" ] || { report_iface_err "Slash" ; exit 1 ; }
- [ "${IFACE/ }" = "$IFACE" ] || { report_iface_err "Space" ; exit 1 ; }
- [ "${IFACE#.}" = "$IFACE" ] || { report_iface_err "Initial dot" ; exit 1 ; }
- [ "${IFACE#-}" = "$IFACE" ] || { report_iface_err "Initial hyphen" ; exit 1 ; }
- [ "${IFACE#\~}" = "$IFACE" ] || { report_iface_err "Initial tilde" ; exit 1 ; }
+ case "$IFACE" in
+ */*) report_iface_err "Slash" ; exit 1 ;;
+ *" "*) report_iface_err "Space" ; exit 1 ;;
+ .*) report_iface_err "Initial dot" ; exit 1 ;;
+ -*) report_iface_err "Initial hyphen" ; exit 1 ;;
+ ~*) report_iface_err "Initial tilde" ; exit 1 ;;
+ esac
;;
*)
report_err "Invalid argument"
The patches below seem to complete it. At least it now seems to work OK
for me. /etc/dhcp3/dhclient-enter-hooks.d/resolvconf would probably
also need to replace ${new_domain_search//\\032/ } with something like
$(echo "$new_domain_search" | sed 's/\\032//'), but since I don't use
dhclient, I haven't touched it.
Stefan
--- /lib/resolvconf/list-records 2006-08-09 09:36:43.000000000 -0400
+++ /tmp/monnier/list-records 2009-03-12 00:50:50.842868010 -0400
@@ -1,5 +1,4 @@
-#!/bin/bash
-# Need bash because we use nullglob, extglob
+#!/bin/sh
#
# list-records
#
@@ -14,6 +13,9 @@
{
RSLT=""
while [ "$1" ] ; do
+ # Only list records of non-zero size
+ [ -s "$1" ] || { shift ; continue ; }
+
for E in $RSLT ; do
[ "$1" = "$E" ] && { shift ; continue 2 ; }
done
@@ -36,15 +38,18 @@
/^$/d
' /etc/resolvconf/interface-order)"
fi
-shopt -s nullglob extglob
+
+# `nullglob' is not indispensable since the test for non-empty files
+# will end up stripping away the patterns that don't correspond to an
+# actual file anyway.
+# `extglob' is not indispensable either because it just changes the set of
+# glob patterns that can be used in /etc/resolvconf/interface-order.
+# Ignore any error while processing shopt since they are normal if /bin/sh is
+# not linked to /bin/bash.
+shopt -s nullglob extglob 2>/dev/null || true
+
# Pathname expansion occurs on the following line resulting, in general,
# in multiple instances of filenames; duplicates must be removed.
uniquify $PATTERNS
-RCRDS=""
-for FLNM in $RSLT ; do
- # Only list records of non-zero size
- [ -s "$FLNM" ] && RCRDS="${RCRDS}${FLNM}
-"
-done
-echo -n "$RCRDS"
+echo "$RSLT"
exit 0
--- /etc/resolvconf/update.d/bind 2006-03-08 12:03:13.000000000 -0500
+++ /tmp/monnier/bind 2009-03-12 00:52:01.523302066 -0400
@@ -1,5 +1,4 @@
-#!/bin/bash
-# Need bash because we use ${foo//bar/baz}
+#!/bin/sh
#
# Script to update the named options file
#
@@ -46,7 +45,7 @@
NMSRVRS=""
if [ "$RSLVCNFFILES" ] ; then
uniquify $(sed -n -e 's/^[[:space:]]*nameserver[[:space:]]\+//p' $RSLVCNFFILES)
- [ "$RSLT" ] && NMSRVRS="${RSLT// /; }; "
+ [ "$RSLT" ] && NMSRVRS="$(echo "$RSLT" | sed 's/ /; /g'); "
fi
# N.B.: After changing directory we no longer have access to the resolv.conf-type files
Stefan Monnier wrote: Thanks for the report. Last time I checked, Essential:yes packages didn't have to be included in the dependency list. Is bash no longer Essential:yes? Or has policy changed?
severity 519364 wishlist
thanks
If such dependencies do not need to be marked, then indeed bash doesn't
need to be mentioned. In this case, I guess my report is a request to
remove this dependency and use just /bin/sh.
Stefan
Thanks for the patch. However, I don't see much advantage in eliminating the dependency on bash. Even if we were to eliminate use of /bin/bash from all resolvconf scripts, one couldn't remove the bash package --- because it's an Essential: yes package. And even if one could, it would only save a little bit of disk space. Given that every change brings with it a risk of breaking something, I am inclined not to make this change.
You do have to confirm very explicitly that you indeed want to remove an
essential package, but other than that, it all works.
Of course I had installed dash (as /bin/sh) first.
need/want things like X11 and Emacs). Debian is pretty good at scaling
down without losing much convenience if any (I did have to forgo
aptitude, for example, but apt-get is still amazingly good compared to
opkg). Relying a bit less on bash would make it yet a bit better in
this respect. And truly, very few packages rely on bash in my
experience. Until now the only other package I bumped into that needed
bash was libpam0 (used in one of the post-inst scripts).
Stefan
PS: To tell you truth, I'm also biased against bash: I find most
bashisms unreadable and I'd bet that only seasoned bashers can remember
what they mean, whereas they can almost always be rewritten using more
traditional constructs (including sed) which are easier to remember
(because sooner or later you have to use sed anyway). Same holds for
zshisms, of course (I'm an avid zsh user).
I'll let the future resolvconf maintainer decide whether or not to implement this wish. Implementing it seems like a not insignificant amount of work, and a not insignificant risk, for rather insignificant benefit.
package resolvconf tags 519364 wontfix stop I won't implement this because it could introduce bugs into resolvconf in return for only minor benefits. If someone were to step forward to maintain resolvconf more energetically than I am doing then they might reconsider this decision.
I considered this wish (#519364) again. I think I will implement a couple of the suggested changes, to reduce the dependency on bashisms where this can be done at no cost. (Some people think it's always good to eliminate bashisms in scripts. The argument is that a script that shebangs bash runs slower than one that shebangs sh (on a system where sh is dash) cuz bash is slower than dash. But that is not true if, in order to make the script POSIX-compliant, built-in bash features have to be replaced by (very slow) invocations of external programs such as sed.) However, list-records enables the extglob bash-option when it interprets patterns in the interface-order file. If this option were disabled then the behavior of resolvconf would change on any system whose interface-order file contains extended glob patterns. I.e., this change could break things. So I'd rather keep extglob enabled. Which means that list-records must shebang bash. Unless you see a way around this.
Thanks for the patch. It allows /sbin/resolvconf to run under [da]sh instead of bash. That's an advantage even if, as I argued earlier, it doesn't eliminate the package's dependency on bash, much less make it possible to remove the bash package (which is Essential and will remain so for some time yet). Will appear in resolvconf 1.61. I also edited the list-records program, inspired by your second patch. Unfortunately list-records can't shebang /bin/sh because it enables extglob. You wrote: That extglob changes (enhances) the set of glob patterns that can be used in interface-order is precisely the reason why we can't disable extglob, which is in turn the reason why we can't shebang /bin/sh. Some people may already be using extended globs and we don't want to break their setups. Cheers,