dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] any subtitution with @/*: ${@#str} or ${*#str} etc
@ 2021-02-06  6:04 Vladimir N. Oleynik
  2021-02-06  7:16 ` Vladimir N. Oleynik
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir N. Oleynik @ 2021-02-06  6:04 UTC (permalink / raw)
  To: dash

Hello.

$ showargs() {
    local i=0 a
    echo \$\#=$#
    for a; do
     echo \$$((i=i+1))=$a
    done
}
$ set -- ab bb bc

$ showargs "${@#b}"
$#=3
$1=ab
$2=bb
$3=bc

but need:
$#=3
$1=ab
$2=b
$3=c

$ showargs "${@%bb}"
$#=2
$1=ab
$2=

but need:
$#=3
$1=ab
$2=
$3=bc

$ echo "${*%b}"
ab bb bc

but need:
a b bc

etc etc

I wanted to make a fix, but the code is easier to completely rewrite
than fix. :(


--w
vodz

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [BUG] any subtitution with @/*: ${@#str} or ${*#str} etc
  2021-02-06  6:04 [BUG] any subtitution with @/*: ${@#str} or ${*#str} etc Vladimir N. Oleynik
@ 2021-02-06  7:16 ` Vladimir N. Oleynik
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir N. Oleynik @ 2021-02-06  7:16 UTC (permalink / raw)
  To: dash

Vladimir N. Oleynik пишет:

> $ echo "${*%b}"
> ab bb bc
> 
> but need:
> a b bc

Interesting moment: bash/ksh produde "a b bc" always, but zsh produce
more funny and like for me:

$ echo ${*%b}
a b bc

$ echo "${*%b}"
ab bb bc

$ echo "${*%c}"
ab bb b

but a knotty logic also:

$ echo "${*#a}"
ab bb bc

$ echo ${*#a}
b bb bc

ohhh

--w
vodz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-06  7:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06  6:04 [BUG] any subtitution with @/*: ${@#str} or ${*#str} etc Vladimir N. Oleynik
2021-02-06  7:16 ` Vladimir N. Oleynik

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).