linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Stephane Chazelas <stephane_chazelas@yahoo.fr>
To: Lukas Czerner <lczerner@redhat.com>
Cc: zkabelac@redhat.com, rwheeler@redhat.com, dchinner@redhat.com,
	LVM general discussion and development <linux-lvm@redhat.com>
Subject: Re: [linux-lvm] [PATCH 01/35] fsadm: Add "create" command
Date: Thu, 22 Sep 2011 11:56:49 +0100	[thread overview]
Message-ID: <20110922105649.GC4407@yahoo.fr> (raw)
In-Reply-To: <alpine.LFD.2.00.1109221057550.4968@dhcp-27-109.brq.redhat.com>

2011-09-22 11:28:36 +0200, Lukas Czerner:
[...]
> > > +	if [ $? -ne 0 ]; then
> > > +		error "FAILED. Exitting!"
> > > +	fi
> > 
> > "$@" || error ...
> 
> I guess it is just a matter of taste.
> 
> > 
> > or
> > 
> > if ! "$@"; then
> >   error ...
> > fi
> 
> That is really not very readable.
[...]

That is how shell works. The syntax is

if
  list-of-commands
then
  other-list-of-commands
else
  yet-another-list-of-commands
fi

I find [ "$?" -ne 0 ] above very confusion and illegible myself.

Why would you run another command that fails if the last one
succeeded? 

> > > +}
> > > +
> > > +is_natural() {
> > > +	test "$1" -ge 0 &> /dev/null && return 1
> > 
> > 
> > &> is a bashism.
> 
> Probably (#!/bin/bash) :)

But it is called "fsadm.sh", that's misleading.

[...]
> > Again, I think that should be either:
> > 
> > set --
> > [ -n "$YES" ] &&
> >   set -- -F
> > dry "mkfs.$fstyp" "$@" -b "$(($bsize*1024))" -E stride="${stride},stripe-width=${stripewidth}" "$device"
> > 
> > or:
> > 
> > force=
> > [ -n "$YES" ] &&
> >   force=-F
> > 
> > eval 'dry "mkfs.$fstyp" '"$force"' -b "$(($bsize*1024))" -E stride="${stride},stripe-width=${stripewidth}" "$device"'
> 
> Ok, I do understand the that I should rather use 'eval', but I do not
> understand why you're trying to get rid of the 'if', it is a bit longer,
> so what ? But is is also more obvious.

"if" is fine, it was just to save me some typing.

> > 
> > [...]
> > > +	is_natural $NEWSIZE
> > > +	[ $? -ne 1 ] && error "$NEWSIZE is not valid number for file system size"
> > 
> > With a fixed is_natural,
> > 
> > is_natural "$NEWSIZE" || error ...
> > 
> > [...]
> > > +	for i in $@; do
> > 
> > for i do
> 
> I am not sure what is wrong with that, it is more obvious and it works
> just fine.

for i in "$@"; do

would have been fine. Again, I can't think of any circumstance
where leaving $@ unquoted would make sense.

-- 
Stephane

  parent reply	other threads:[~2011-09-22 10:56 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-21 16:45 [linux-lvm] [RFC][PATCH 00/35] fsadm update Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 01/35] fsadm: Add "create" command Lukas Czerner
2011-09-21 19:00   ` Stephane Chazelas
2011-09-22  9:28     ` Lukas Czerner
2011-09-22 10:01       ` Zdenek Kabelac
2011-09-22 10:27         ` Lukas Czerner
2011-09-22 10:56       ` Stephane Chazelas [this message]
2011-09-21 16:45 ` [linux-lvm] [PATCH 02/35] fsadm: Add "destroy" command Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 03/35] fsadm: Add "list" command Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 04/35] fsadm: Make "create" command more vg aware Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 05/35] fsadm: Teach "destroy" command to take more arguments Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 06/35] fsadm: Simple cleanup and comment update Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 07/35] fsadm: Create "add" command Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 08/35] fsadm: Update "list" command for better alignment Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 09/35] fsadm: Specify number of stripes when no device is given Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 10/35] fsadm: Print type of the volume in filesystem listing Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 11/35] fsadm: Add "remove" command Lukas Czerner
2011-09-22 10:06   ` Zdenek Kabelac
2011-09-22 10:36     ` Lukas Czerner
2011-09-22 10:43       ` Zdenek Kabelac
2011-09-22 10:52         ` Lukas Czerner
2011-09-22 11:41           ` Zdenek Kabelac
2011-09-21 16:45 ` [linux-lvm] [PATCH 12/35] fsadm: Try to avoid calling LVM in the loops Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 13/35] fsadm: Merge "destroy" and "remove" into one command Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 14/35] fsadm: Allow to remove all volume groups Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 15/35] fsadm: Make all internal math in kilobytes Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 16/35] fsadm: Use warn for warnings in list command Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 17/35] fsadm: Handle resize if there is no file system Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 18/35] fsadm: Fsck extN before resize only if it is not mounted Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 19/35] fsadm: Align numbers to the decimal point Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 20/35] fsadm: Add simple configuration file Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 21/35] fsadm: Use DEFAULT_POOL when creating volume group Lukas Czerner
2011-09-22 10:09   ` Zdenek Kabelac
2011-09-21 16:45 ` [linux-lvm] [PATCH 22/35] fsadm: Add LVOL_PREFIX configuration option Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 23/35] fsadm: Only use readlink if link is provided Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 24/35] fsadm: Remove unnecessary modification of PATH variable Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 25/35] fsadm: Allow to specify size without "size=" prefix in "resize" Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 26/35] fsadm: Allow to specify lv in vg/lv format Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 27/35] fsadm: error out when no size is provided in resize Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 28/35] fsadm: Umount ext2 file system prior resize Lukas Czerner
2011-09-22 10:28   ` Zdenek Kabelac
2011-09-21 16:45 ` [linux-lvm] [PATCH 29/35] lvresize: Specify --resize-fs-only when going to use fsadm resize Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 30/35] test: add helper to compute aligned lv size Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 31/35] fsadm: Add help for new commands and update man page Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 32/35] fsadm: Update authorship of the fsadm Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 33/35] test: Add test for fsadm add command Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 34/35] test: Add test for fsadm create command Lukas Czerner
2011-09-21 16:45 ` [linux-lvm] [PATCH 35/35] test: Add test for fsadm resize command Lukas Czerner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110922105649.GC4407@yahoo.fr \
    --to=stephane_chazelas@yahoo.fr \
    --cc=dchinner@redhat.com \
    --cc=lczerner@redhat.com \
    --cc=linux-lvm@redhat.com \
    --cc=rwheeler@redhat.com \
    --cc=zkabelac@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).