All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ruediger Meier <sweet_f_a@gmx.de>
To: kerolasa@gmail.com
Cc: Karel Zak <kzak@redhat.com>,
	Benno Schulenberg <bensberg@justemail.net>,
	"Util-Linux" <util-linux@vger.kernel.org>
Subject: Re: [PATCH 4/4] docs: setterm.1 clean up manual page groff style
Date: Mon, 2 Jun 2014 00:35:39 +0200	[thread overview]
Message-ID: <201406020035.40358.sweet_f_a@gmx.de> (raw)
In-Reply-To: <CAG27Bk02R6UE4qqws=KOh5YKZ+hZJUyM1i8Z2dZ0h65a5Bpu2A@mail.gmail.com>

On Friday 30 May 2014, Sami Kerola wrote:
> On 29 May 2014 11:23, Ruediger Meier <sweet_f_a@gmx.de> wrote:
> > On Thursday 29 May 2014, Sami Kerola wrote:
> >> On 27 May 2014 15:46, Karel Zak <kzak@redhat.com> wrote:
> >> > On Mon, May 26, 2014 at 04:46:12PM +0100, Sami Kerola wrote:
> >> >> git://github.com/kerolasa/lelux-utiliteetit.git rename
> >> >
> >> >  Not merged, it seems that the tests still uses the current
> >> > directory rather than $TS_OUTDIR, right?
> >>
> >> Oh, that's a beginner mistake. Fix is available in same git remote
> >> location. All I did was a cd before file operations in each
> >> script, something like this:
> >>
> >> +++ b/tests/ts/rename/basic
> >> @@ -22,6 +22,7 @@ TS_DESC="basic check"
> >>  ts_init "$*"
> >>
> >>  ts_check_test_command "$TS_CMD_RENAME"
> >> +cd $TS_OUTDIR
> >
> > I know we are doing similar already in other tests too. IMO cd in
> > scripts can be very dangerous, specially if there is no error
> > handling.
> >
> > For example if ts_init is broken (while you are working on it) and
> > TS_OUTDIR would be unset then "cd $TS_OUTDIR" would jump into your
> > $HOME ... which could be really bad.
> >
> > At least I would quote it
> >   cd "$TS_OUTDIR"
> > or even better
> >   cd "$TS_OUTDIR" || exit 1
>
> Hi Rudi,
>
> Good point. I changed my git to have the better change dir you
> proposed.

BTW I just noticed that bash's
$ cd ''
does NOT return error. But
$ /usr/bin/cd ''
does like it should IMO.

> What would you think adding exit on error[1], disallow referrals to
> unset variables[2], and make any errors in pipe chains to cause exit
> on error to blow up[3], as default in ts_init()? I use in my own
> scripts these as default settings, and when I refactor scripts I tend
> to add these to make them more robust. Down side is that these
> settings often cause quite a bit changes, which would mean the change
> should not be considered before the release v2.25 is out.

I'am not fully convinced about this. It would require much review and 
code change of all tests and functions.

> [1] set -e && trap 'ts_failed "exit on error"' ERR
> [2] set -u
> [3] set -o pipefail

IMO "pipefail" and "-e" are very debatable. Sometimes I like pipefail 
but mostly not. Look for example something like this "do something with 
some files if we found one":
$ ls | grep "a-file-which-exists-sometimes" | xargs -r do_something

pipefail would mess up do_something's return value. And "-e" would even 
abort the script.

$ file_list=$(ls | grep "a-file-which-exists-sometimes")
would also fail with "-e". 

I'm even a bit unhappy that currently some tests have already "set -o 
pipefail". It may break certain functions sourced from 
tests/functions.sh. It's very hard to write global shell functions 
which would survive any shopt combination.

cu,
Rudi

  reply	other threads:[~2014-06-01 22:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-24 11:08 [PATCH 0/4] setterm: documentation updates Sami Kerola
2014-05-24 11:08 ` [PATCH 1/4] setterm: add usage() descriptions Sami Kerola
2014-05-24 12:30   ` Benno Schulenberg
2014-05-25 10:57     ` Sami Kerola
2014-05-25 20:51       ` Benno Schulenberg
2014-05-24 11:08 ` [PATCH 2/4] docs: setterm.1 add missing options to manual page and remove duplicate Sami Kerola
2014-05-24 12:33   ` Benno Schulenberg
2014-05-25 10:57     ` Sami Kerola
2014-05-24 11:08 ` [PATCH 3/4] docs: setterm.1 add options compatibility note Sami Kerola
2014-05-24 12:38   ` Benno Schulenberg
2014-05-25 10:58     ` Sami Kerola
2014-05-24 11:08 ` [PATCH 4/4] docs: setterm.1 clean up manual page groff style Sami Kerola
2014-05-24 12:44   ` Benno Schulenberg
2014-05-25 10:58     ` Sami Kerola
2014-05-25 21:10       ` Benno Schulenberg
2014-05-26  8:42         ` Sami Kerola
2014-05-26 10:11           ` Karel Zak
2014-05-26 15:46             ` Sami Kerola
2014-05-27 14:46               ` Karel Zak
2014-05-29  9:48                 ` Sami Kerola
2014-05-29 10:23                   ` Ruediger Meier
2014-05-30  7:44                     ` Sami Kerola
2014-06-01 22:35                       ` Ruediger Meier [this message]
2014-06-02 16:42                         ` Sami Kerola
2014-06-02 21:23                           ` Bernhard Voelker
2014-06-02 21:35                             ` Ruediger Meier

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=201406020035.40358.sweet_f_a@gmx.de \
    --to=sweet_f_a@gmx.de \
    --cc=bensberg@justemail.net \
    --cc=kerolasa@gmail.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.