Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > gnu.bash.bug > #16852

Re: Bash parameter expansion (remove largest trailing match, remove largest leading match, pattern replacement) does not work

From Koichi Murase <myoga.murase@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 2020-08-30 04:27 +0900
Message-ID <mailman.1730.1598729272.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> <CAFLRLk9CBn1CUchi5tHmZ7FitWWpLaVc-Sxyr7=AuGRAQXWe9Q@mail.gmail.com>

Show all headers | View raw


2020年8月30日(日) 3:55 Bruce Lilly <bruce.lilly@gmail.com>:
> Please don't assume that something output by printf (without
> quoting) for clarity is representative of actual expansion by the
> shell when properly quoted.

Please don't assume that I have assumed something strange.  To begin
with, you didn't provide the script `shellbug', so something needs to
be assumed anyway.  Since it seems you are aware that your original
post would be unclear and confuse others, you could have just included
the contents of the file `shellbug'.  Anyway, I did NOT assume that
you have literally written broken quoting like

  separator2(octal escape)=\057
  pattern1=${number1}(${separator1})

I assumed that you have written like

  separator2='\057'
  pattern1="${number1}(${separator1})"

because otherwise, it doesn't work with ksh93 either.


To explain it in more detail, first, these parameter expansions work
for me with separator1='/'.  The pattern that you constructed from
separator2='\057' is just not supported by Bash.  Next, you specify
exactly the same script `shellbug' to both Bash and ksh93, so I could
assume that you are missing the Bash-specific `shopt -s extglob' in
the script because otherwise, ksh93 would have complained it.  That is
all what I can guess from your original post.

--
Koichi

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Bash parameter expansion (remove largest trailing match, remove largest leading match, pattern replacement) does not work Koichi Murase <myoga.murase@gmail.com> - 2020-08-30 04:27 +0900

csiph-web