All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Mikko.Rapeli@bmw.de>
To: <clarson@kergoth.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: shell script guidelines in oe-core? (was Re: [PATCH v4] create-pull-request: cleanup bashisms)
Date: Thu, 13 Aug 2015 06:27:38 +0000	[thread overview]
Message-ID: <20150813062742.GN6102@loska> (raw)
In-Reply-To: <CABcZANkHBUNH5Zo3opKT-uwfneMYghTBTJCV8awOm-6D_0SK1w@mail.gmail.com>

On Wed, Aug 12, 2015 at 10:51:26AM -0700, Christopher Larson wrote:
> That reminds me, there's a shell portability issue / standards-complaince
> issue that's not identified by shellcheck. Typically, to negate a  bracket
> expression in a regular expression, one uses ^, e.g. [^a-z] is everything
> that isn't in the range a to z, but that's not the case in shell, e.g. at a
> prompt or in a ${foo#<pattern>}:
> 
>     "[...]a bracket expression as in XBD *RE Bracket Expression* , except
> that the <exclamation-mark> character ( '!' ) shall replace the
> <circumflex> character ( '^' ) in its role in a non-matching list in the
> regular expression notation"
> 
> So in shell, you'd want [!a-z] rather than [^a-z]. Nearly all shells handle
> both, but the behavior of the latter is actually unspecified according to
> the standard:
> 
>     "A bracket expression starting with an unquoted <circumflex> character
> produces unspecified results."
> 
> I recently got bitten by this with one of my shell scripts on a system
> running dash.

Does checkbashisms warn about this?

-Mikko

  reply	other threads:[~2015-08-13  6:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05  9:01 [PATCH] create-pull-request: cd to relative directory Ed Bartosh
2015-08-06  3:33 ` Khem Raj
2015-08-06  8:38   ` Paul Eggleton
2015-08-06  9:07     ` Ed Bartosh
2015-08-06 15:05     ` Khem Raj
2015-08-06 15:16       ` Paul Eggleton
2015-08-06 16:16         ` Khem Raj
2015-08-11 14:24   ` [PATCH v2] " Ed Bartosh
2015-08-11 14:33   ` [PATCH v3] " Ed Bartosh
2015-08-12  9:33     ` [PATCH v4] create-pull-request: cleanup bashisms Ed Bartosh
2015-08-12  9:35       ` Khem Raj
2015-08-12  9:49       ` shell script guidelines in oe-core? (was Re: [PATCH v4] create-pull-request: cleanup bashisms) Mikko.Rapeli
2015-08-12 16:56         ` Khem Raj
2015-08-12 17:46           ` Christopher Larson
2015-08-12 17:51             ` Christopher Larson
2015-08-13  6:27               ` Mikko.Rapeli [this message]
2015-08-14 22:01                 ` Christopher Larson
2015-08-16  1:38                   ` Christopher Larson
2015-08-17  6:14                     ` Mikko.Rapeli
2015-08-17 10:52                       ` Otavio Salvador

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=20150813062742.GN6102@loska \
    --to=mikko.rapeli@bmw.de \
    --cc=clarson@kergoth.com \
    --cc=openembedded-core@lists.openembedded.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.