[parted-devel] [PATCH] Detect Ext4 (Parted Alioth #188)

Jim Meyering jim at meyering.net
Wed Jan 7 06:21:54 UTC 2009


"Debarshi Ray" <debarshi.ray at gmail.com> wrote:
>> make the test "skip" (not fail) if mkfs.ext4 fails.
>> That may save us some reports of test failures on systems
>> lacking ext4 support.
>
> Two queries.
>
> 1. Can we use the test_skip function to skip one iteration of the for
> loop? Or this is fine:
>     which mkfs.$type >/dev/null 2>&1

"which" is not portable enough.
Please do something like this instead:

  ( mkfs.$type -V ) > /dev/null 2>&1 ||
    { echo "no $type support; skipping that test"; continue; }

Ran mkfs.$type in a ( subshell ) so that if the command is missing,
stderr from the invoking shell will still go to /dev/null.

Also note that even if echo fails, we still want to "continue;"
hence I used ";", not "&&" between them.

Finally, I prefer to use
  cmd || { ... }
rather than
  cmd
  test $? ...
so that it's harder for them to be accidentally separated.

>     [ $? -eq 1 ] &&

BTW, what if it fails with exit status 2 or 255 when mkfs.$type
isn't installed?  Best not to compare against a particular
non-zero value at all.

>         echo 'no $type support' &&
>         continue
>
> 2. The $type is not getting expanded to ext[234] in the messages:

As above, use double quotes if you want the "$type" to be expanded.

>     [rishi at ginger tests]$ ./t1700-ext-probe.sh
>     *   ok 1: create an $type file system
>     *   ok 2: probe the $type file system
>     *   ok 3: create an $type file system
>     *   ok 4: probe the $type file system
>     *   ok 5: create an $type file system
>     *   ok 6: probe the $type file system
>     * passed all 6 test(s)
>     [rishi at ginger tests]$



More information about the parted-devel mailing list