Re: [systemd-devel] [PATCH 12/12] Add mock fsck process
Le 28/01/2015 17:13, Martin Pitt a écrit : Zbigniew Jędrzejewski-Szmek [2015-01-28 16:08 +0100]: +#!/bin/bash I think you can change this to /bin/sh, I don't see any bashisms. +declare -a maxpass=(30 5 2 30 60) I do :-) POSIX shell doesn't have arrays AFAIK, and declare -a definitively doesn't work in e. g. dash. +for pass in {1..5}; do +maxprogress=${maxpass[$((pass-1))]} That said, if using POSIX shell is a concern (probably not for this little test dummy), this could certainly be rewritten to something like pass=0 for maxprogress in 30 5 2 30 60; do pass=$((pass+1)) which isn't really more complicated and avoids arrays. Yeah, there are some bashims. If getting POSIX shell is important for the mock, I'm happy to do the necessary changes. Didier ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 12/12] Add mock fsck process
Zbigniew Jędrzejewski-Szmek [2015-01-28 16:08 +0100]: > > +#!/bin/bash > I think you can change this to /bin/sh, I don't see any bashisms. > > > +declare -a maxpass=(30 5 2 30 60) I do :-) POSIX shell doesn't have arrays AFAIK, and declare -a definitively doesn't work in e. g. dash. > > +for pass in {1..5}; do > > +maxprogress=${maxpass[$((pass-1))]} That said, if using POSIX shell is a concern (probably not for this little test dummy), this could certainly be rewritten to something like pass=0 for maxprogress in 30 5 2 30 60; do pass=$((pass+1)) which isn't really more complicated and avoids arrays. Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 12/12] Add mock fsck process
On Wed, Jan 28, 2015 at 02:25:17PM +0100, Didier Roche wrote: > > From aefe0667ed62d5d7e17193c0f5ae302ed57e4727 Mon Sep 17 00:00:00 2001 > From: Didier Roche > Date: Mon, 26 Jan 2015 17:46:36 +0100 > Subject: [PATCH 12/12] Add mock fsck process > > --- > test/mocks/fsck | 27 +++ > 1 file changed, 27 insertions(+) > create mode 100755 test/mocks/fsck > > diff --git a/test/mocks/fsck b/test/mocks/fsck > new file mode 100755 > index 000..77b50d7 > --- /dev/null > +++ b/test/mocks/fsck > @@ -0,0 +1,27 @@ > +#!/bin/bash I think you can change this to /bin/sh, I don't see any bashisms. > +fd=0 > + > +OPTIND=1 > +while getopts "C:aTlM" opt; do > +case "$opt" in > +C) > +fd=$OPTARG > +;; > +\?);; > +esac > +done > + > +shift "$((OPTIND-1))" > +device=$1 > + > +echo "Running fake fsck on $device" > + > +declare -a maxpass=(30 5 2 30 60) > + > +for pass in {1..5}; do > +maxprogress=${maxpass[$((pass-1))]} > +for (( current=0; current<=${maxprogress}; current++)); do > +echo "$pass $current $maxprogress $device">&$fd > +sleep 0.1 > +done > +done > -- > 2.1.4 > > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 12/12] Add mock fsck process
>From aefe0667ed62d5d7e17193c0f5ae302ed57e4727 Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Mon, 26 Jan 2015 17:46:36 +0100 Subject: [PATCH 12/12] Add mock fsck process --- test/mocks/fsck | 27 +++ 1 file changed, 27 insertions(+) create mode 100755 test/mocks/fsck diff --git a/test/mocks/fsck b/test/mocks/fsck new file mode 100755 index 000..77b50d7 --- /dev/null +++ b/test/mocks/fsck @@ -0,0 +1,27 @@ +#!/bin/bash +fd=0 + +OPTIND=1 +while getopts "C:aTlM" opt; do +case "$opt" in +C) +fd=$OPTARG +;; +\?);; +esac +done + +shift "$((OPTIND-1))" +device=$1 + +echo "Running fake fsck on $device" + +declare -a maxpass=(30 5 2 30 60) + +for pass in {1..5}; do +maxprogress=${maxpass[$((pass-1))]} +for (( current=0; current<=${maxprogress}; current++)); do +echo "$pass $current $maxprogress $device">&$fd +sleep 0.1 +done +done -- 2.1.4 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel