[Pkg-sysvinit-devel] Bug#339979: Minor cosmetic problems with
lastest initscripts
Thomas Hood
jdthood at yahoo.co.uk
Wed Nov 23 16:10:03 UTC 2005
Domenico Pasella wrote:
>> Scripts can be sourced with positional parameters, so I don't see what
>> is wrong with the code at line 336 of checkroot.sh, which you quote.
>> Can you explain?
>
> I was sleeping. :)
No you weren't. I just discovered that providing positional parameters
to sourced scripts is not supported in dash. Do you have /bin/sh linked
to dash?
=========
$ cat /tmp/s
echo arg0 "$0" arg1 "$1"
$ cat /tmp/t
#!/bin/bash
. /tmp/s foo
$ /tmp/t
arg0 /tmp/t arg1 foo
$ vi /tmp/t # and s/bash/dash
$ cat /tmp/t
#!/bin/dash
. /tmp/s foo
$ /tmp/t
arg0 /tmp/t arg1
==========
> Wed Nov 23 16:19:13 2005: Done checking root file system.
> Wed Nov 23 16:19:13 2005: Usage: /etc/rcS.d/S10checkroot.sh start|stop
> Wed Nov 23 16:19:13 2005: Cleaning up ifupdown...done.
Doh, I forgot to fix the Usage line in mountvirtfs. Please apply
this patch to your mountvirtfs:
- echo "Usage: $0 start|stop" >&2
+ echo "Usage: mountvirtfs start|stop" >&2
Assuming that you are using dash and that this is the reason you are
seeing the message, the next question is whether dash or checkroot.sh is
at fault. That is, _should_ dash support sourcing with arguments?
Sourcing is performed using the dot command which, like the colon command,
is a "Special Built-in Utility"[0]. The Open Group Base Specification
Issue 6 does not say[1] that the dot can be given more than one argument.
Hence, I conclude that the bug is in checkroot.sh: a bashism.
[0]http://www.opengroup.org/onlinepubs/009695399/idx/sbi.html
[1]http://www.opengroup.org/onlinepubs/009695399/utilities/dot.html
I will fix this by removing the 'start' argument of the dot command you
quoted and I will make mountvirtfs default to start if $1 is empty.
Here is a diff for you to try.
$ svn diff
Index: checkroot.sh
===================================================================
--- checkroot.sh (revision 213)
+++ checkroot.sh (working copy)
@@ -335,7 +335,7 @@
[ "$roottype" != none ] &&
mount -f -o $rootopts -t $roottype $fstabroot /
[ -n "$devfs" ] && mount -f $devfs
- . /etc/init.d/mountvirtfs start
+ . /etc/init.d/mountvirtfs
fi
#
Index: mountvirtfs
===================================================================
--- mountvirtfs (revision 214)
+++ mountvirtfs (working copy)
@@ -237,7 +237,7 @@
}
case "$1" in
- start)
+ start|"")
do_start
;;
restart|reload|force-reload)
@@ -248,7 +248,7 @@
# No-op
;;
*)
- echo "Usage: mountvirtfs start|stop" >&2
+ echo "Usage: mountvirtfs [start|stop]" >&2
exit 3
;;
esac
--
Thomas
More information about the Pkg-sysvinit-devel
mailing list