Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > gnu.bash.bug > #16863
| Path | csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Ilkka Virta <itvirta@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Bash parameter expansion (remove largest trailing match, remove largest leading match, pattern replacement) does not work |
| Date | Sun, 30 Aug 2020 10:47:11 +0300 |
| Lines | 64 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1756.1598773647.2469.bug-bash@gnu.org> (permalink) |
| References | <CAPyES363zNvUZHWo6imXOyC3UPU5FAbsyFGzWkcJMO-HBhT6gQ@mail.gmail.com> <CAFLRLk_k+J3-Nt9UJ4Fb8c-RewPnVjf_b=ShqGGASG0GmREAhg@mail.gmail.com> <CAPyES3685SjyZfrL+M_56wGqxvh=N9xNchWJ1xqMSrmmEJb9ww@mail.gmail.com> <CAMLQOtQtYxMiiP9=nN72AKC+hKTJ06rLxM7=Nt5LF1M47jvWrA@mail.gmail.com> <CAPyES36MM0OL2gDnaqfpywoyRwk29NWSXWTNFSCgA4a+jBfENQ@mail.gmail.com> <CAFLRLk8eb+PNzuGp_teBrEZC=U1oHMa66vFcch3pH=eEmt6+=Q@mail.gmail.com> <CAPyES34VNuisQZy-pa75yL2MPzrR8UoD_bwZp6B8eR7Ko=xG0g@mail.gmail.com> <CAMLQOtTQiq4N-n8nBLfgN7i36N37DciC_VmRgK_F9NA=2bR1_w@mail.gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| X-Trace | usenet.stanford.edu 1598773648 2765 209.51.188.17 (30 Aug 2020 07:47:28 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash@gnu.org |
| To | Bruce Lilly <bruce.lilly@gmail.com> |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9/o3aECbqhnDrSIkK4Vckvsid4bxQ8sNg5WmiQswigc=; b=LX5Sx/ltf8Ksi7ENfOKA37j7pr8oaU3UwyC7YPee+Jf0Ln09ZwsbQ+P5BYeKs6M3+j uy+1Kji1/7uTgIncDrdaTu8EvX+UIn/l/syn/jEkxW8F5CD/baBnAWwtIxxQ5H7cQAY9 2liWu8BW8rK2mug3z6hfFyp3+DzazIETxiMKeXJfzH3F2wimtbBB5FsOKCb2MNPa5tk6 PSir+scxSXFlzevyz/k1D+cQ+pWuToxrXgm6O2jH8IF46/FzcOg9CIHPHH/8q3hyQN+J KbdEPZavU6HMoZYdG3DfiucrPKfpm4Wvkns1janqTe5J8p+cNflRu8errdtoUkWXjaun 395A== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9/o3aECbqhnDrSIkK4Vckvsid4bxQ8sNg5WmiQswigc=; b=dVS+NLhrDcHMBHtgIcfHZuiMDLn4T2j6biYUUFy4aaQMZoA5rjAlOapdbpClyDmFpI ZauOTM+w++6CMQ30gsBhc2+rJ3cVzLTktATJRMLAOkZO+XtvCRbaAhb52xhal1OwWxAl 5HXiQGaWxvOfR+jhGDKeotegtKLE+tT3XT7hsLavhRGhio2VnkdWwgaFsqxMQ2XP9EQS EVHH20FrAIzMaCB/Lsr6JBJ2VasRTq9uf0CuZw/xKeOrG19mgnoWKYX5xNX0UkDS1kQ3 iVZvqJOM26sscl9zzFUfKJ7FovB9ubKSJMOq7Arh3KOtm2/UkkEBu78hQkszYt9qZqAo oqyQ== |
| X-Gm-Message-State | AOAM530uKxTcRxtrKQDX4GpmMSIU9OWDv0o63tuigL6umY575/sOD2WU 1llj38BdrDbrs9Ffskabbt8/wJ3/DaNJeuQgm4c= |
| X-Google-Smtp-Source | ABdhPJyEGfyKLvCcdWGap6fLFqzsyYyQWqiAkc70ug7yoWFh4qPrxuxmkZnPaX+xftS7whh1/BOn2j6FK+uvbbgmiNM= |
| X-Received | by 2002:a2e:8197:: with SMTP id e23mr3058816ljg.406.1598773643126; Sun, 30 Aug 2020 00:47:23 -0700 (PDT) |
| In-Reply-To | <CAPyES34VNuisQZy-pa75yL2MPzrR8UoD_bwZp6B8eR7Ko=xG0g@mail.gmail.com> |
| Received-SPF | pass client-ip=2a00:1450:4864:20::235; envelope-from=itvirta@gmail.com; helo=mail-lj1-x235.google.com |
| X-detected-operating-system | by eggs.gnu.org: No matching host in p0f cache. That's all we know. |
| X-Spam_score_int | -20 |
| X-Spam_score | -2.1 |
| X-Spam_bar | -- |
| X-Spam_report | (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no |
| X-Spam_action | no action |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.23 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <https://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAMLQOtTQiq4N-n8nBLfgN7i36N37DciC_VmRgK_F9NA=2bR1_w@mail.gmail.com> |
| X-Mailman-Original-References | <CAPyES363zNvUZHWo6imXOyC3UPU5FAbsyFGzWkcJMO-HBhT6gQ@mail.gmail.com> <CAFLRLk_k+J3-Nt9UJ4Fb8c-RewPnVjf_b=ShqGGASG0GmREAhg@mail.gmail.com> <CAPyES3685SjyZfrL+M_56wGqxvh=N9xNchWJ1xqMSrmmEJb9ww@mail.gmail.com> <CAMLQOtQtYxMiiP9=nN72AKC+hKTJ06rLxM7=Nt5LF1M47jvWrA@mail.gmail.com> <CAPyES36MM0OL2gDnaqfpywoyRwk29NWSXWTNFSCgA4a+jBfENQ@mail.gmail.com> <CAFLRLk8eb+PNzuGp_teBrEZC=U1oHMa66vFcch3pH=eEmt6+=Q@mail.gmail.com> <CAPyES34VNuisQZy-pa75yL2MPzrR8UoD_bwZp6B8eR7Ko=xG0g@mail.gmail.com> |
| Xref | csiph.com gnu.bash.bug:16863 |
Show key headers only | View raw
On Sat, Aug 29, 2020 at 11:13 PM Bruce Lilly <bruce.lilly@gmail.com> wrote:
> It's a bit more complicated than that; if, for example, some excerpt ended
> up in regression tests, there would be a question about whether or not
> there was a copyright violation. As I understand the GPL (IANAL), it
> requires all parts of a "work" to be GPL'd, and that wouldn't be possible
> for any parts of the script that ended up in bash regression tests.
>
That's hilarious. People post proof-of-concept scripts and code snippets as
part of bug
reports and such every day. If you'd just reduced the problem to a simple
demonstration
(below), you could have explicitly licensed it under the GPL if you were
afraid someone might
want to include it to a GPL'd software. In any case, for a one-liner like
this, it might not even
be copyrightable (at least not everywhere) as pretty much lacks any
creativity. I'd also assume
that test scripts often aren't even compiled with the main program, just
aggregated to the
code distribution. Anyway, it wouldn't be you doing the copyright violation
if someone used
your snippet without license.
Bash and ksh indeed differ in this:
$ bash -c 'str=foo/; sep="\057"; printf %s\\n ${str%%$sep}'
foo/
$ ksh -c 'str=foo/; sep="\057"; printf %s\\n ${str%%$sep}'
foo
And there's nothing in the Bash manuals that says \057 should be taken as
an octal
escape in a pattern match. The workarounds to that are either sep=$'\057'
which is
documented to accept escapes like this, or sep=/ which just works in the
obvious manner.
I do wonder why you'd even bother with trying the octal escape here instead
of just writing
the slash as a slash. Something like \001 would be different, of course.
The fact that $'\057'
does what you seem to want is exactly the part where you might have used a
form of quoting
which would have worked, but there was no way for the reader to check that
because you
hid the code.
$'' is described here:
https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
(search for 'octal')
Of course, you also appear to have missed extglob, which I guess is
understandable if you're
coming from ksh. But even so, reducing the problem to smaller, easier to
debug pieces would
have shown the difference there, too, separately from the differences in
handling of octal escapes.
And perhaps led you to read the rest of what the manual says on Pattern
Matching, from the exact
page you linked to. ("If the extglob shell option is enabled using the
shopt builtin, several extended
pattern matching operators are recognized...")
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Bash parameter expansion (remove largest trailing match, remove largest leading match, pattern replacement) does not work Ilkka Virta <itvirta@gmail.com> - 2020-08-30 10:47 +0300
csiph-web