Dash Archive mirror
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@Shaw.ca>
To: Herbert Xu <dash@vger.kernel.org>
Cc: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Subject: dash 0.5.12 parameter expansion using classes not working
Date: Tue, 7 Feb 2023 22:14:18 -0700	[thread overview]
Message-ID: <12629edc-ec41-ca2a-968b-3be7de2743ae@Shaw.ca> (raw)

[-- Attachment #1: Type: text/plain, Size: 1119 bytes --]

Hi folks,

Under dash 0.5.12 parameter expansion using regexp classes [[:space:]] to trim 
no longer works, but releases up to 0.5.11.5 still work correctly with the same 
environment and default config options.

In the attached dash script and logs, one of our users has an abstruse string 
they use to clean up build command lines, but I trimmed that down to the 
locale-dependent [[:space:]] regexp, then to the ASCII whitespace characters 
generated by echo, and only the last still works with 0.5.12, all work under 
0.5.11.5.

Nothing obvious jumps out from the commitdiffs between then and now, so I am 
hoping some possible cause occurs to you.

Build environment was Cygwin+newlib autoreconf with autoconf 2.71, autogen 
5.18.16, automake 1.16.5, gcc 11.3, binutils 2.29, coreutils 9.0, dash 0.5.11.5 
as sh.

-- 
Take care. Thanks, Brian Inglis			Calgary, Alberta, Canada

La perfection est atteinte			Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter	not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer	but when there is no more to cut
			-- Antoine de Saint-Exupéry

[-- Attachment #2: par-ext-t.sh --]
[-- Type: text/plain, Size: 802 bytes --]

#!/bin/dash -vx

trim() {
  # remove leading whitespace characters
  __trim="${*#${*%%[![:space:]]*}}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%${__trim##*[![:space:]]}}"
}

trim " alpha" | od -t x1a
trim "beta " | od -t x1a
trim "\rgamma	" | od -t x1a

trim2() {
  # remove leading whitespace characters
  __trim="${*##[[:space:]]}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%%[[:space:]]}"
}

trim2 " alpha" | od -t x1a
trim2 "beta " | od -t x1a
trim2 "\rgamma	" | od -t x1a

trim3() {
  _space="$(echo -n '[\b\t\n\v\f\r ]')"
  # remove leading whitespace characters
  __trim="${*##$_space}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%%$_space}"
}

trim3 " alpha" | od -t x1a
trim3 "beta " | od -t x1a
trim3 "\rgamma	" | od -t x1a


[-- Attachment #3: test11.log --]
[-- Type: text/plain, Size: 2026 bytes --]

#!/bin/dash -vx

trim() {
  # remove leading whitespace characters
  __trim="${*#${*%%[![:space:]]*}}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%${__trim##*[![:space:]]}}"
}

trim " alpha" | od -t x1a
+ trim  alpha
+ __trim=alpha
+ printf %s alpha
+ od -t x1a
0000000  61  6c  70  68  61
          a   l   p   h   a
0000005
trim "beta " | od -t x1a
+ trim beta 
+ __trim=beta 
+ printf %s beta
+ od -t x1a
0000000  62  65  74  61
          b   e   t   a
0000004
trim "\rgamma	" | od -t x1a
+ trim \rgamma	
+ __trim=gamma	
+ printf %s gamma
+ od -t x1a
0000000  67  61  6d  6d  61
          g   a   m   m   a
0000005

trim2() {
  # remove leading whitespace characters
  __trim="${*##[[:space:]]}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%%[[:space:]]}"
}

trim2 " alpha" | od -t x1a
+ trim2  alpha
+ __trim=alpha
+ printf %s alpha
+ od -t x1a
0000000  61  6c  70  68  61
          a   l   p   h   a
0000005
trim2 "beta " | od -t x1a
+ trim2 beta 
+ __trim=beta 
+ printf %s beta
+ od -t x1a
0000000  62  65  74  61
          b   e   t   a
0000004
trim2 "\rgamma	" | od -t x1a
+ trim2 \rgamma	
+ __trim=gamma	
+ printf %s gamma
+ od -t x1a
0000000  67  61  6d  6d  61
          g   a   m   m   a
0000005

trim3() {
  _space="$(echo -n '[\b\t\n\v\f\r ]')"
  # remove leading whitespace characters
  __trim="${*##$_space}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%%$_space}"
}

trim3 " alpha" | od -t x1a
+ trim3  alpha
+ od -t x1a
+ echo -n [\b\t\n\v\f\r ]
+ _space=[\b	
\v\f\r ]
+ __trim=alpha
+ printf %s alpha
0000000  61  6c  70  68  61
          a   l   p   h   a
0000005
trim3 "beta " | od -t x1a
+ trim3 beta 
+ od -t x1a
+ echo -n [\b\t\n\v\f\r ]
+ _space=[\b	
\v\f\r ]
+ __trim=beta 
+ printf %s beta
0000000  62  65  74  61
          b   e   t   a
0000004
trim3 "\rgamma	" | od -t x1a
+ trim3 \rgamma	
+ + od -t x1a
echo -n [\b\t\n\v\f\r ]
+ _space=[\b	
\v\f\r ]
+ __trim=gamma	
+ printf %s gamma
0000000  67  61  6d  6d  61
          g   a   m   m   a
0000005


[-- Attachment #4: test12.log --]
[-- Type: text/plain, Size: 1874 bytes --]

#!/bin/dash -vx

trim() {
  # remove leading whitespace characters
  __trim="${*#${*%%[![:space:]]*}}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%${__trim##*[![:space:]]}}"
}

trim " alpha" | od -t x1a
+ trim  alpha
+ __trim=
+ printf %s 
+ od -t x1a
0000000
trim "beta " | od -t x1a
+ trim beta 
+ __trim=
+ printf %s 
+ od -t x1a
0000000
trim "\rgamma	" | od -t x1a
+ trim \rgamma	
+ __trim=
+ printf %s 
+ od -t x1a
0000000

trim2() {
  # remove leading whitespace characters
  __trim="${*##[[:space:]]}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%%[[:space:]]}"
}

trim2 " alpha" | od -t x1a
+ trim2  alpha
+ __trim= alpha
+ printf %s  alpha
+ od -t x1a
0000000  20  61  6c  70  68  61
         sp   a   l   p   h   a
0000006
trim2 "beta " | od -t x1a
+ trim2 beta 
+ __trim=beta 
+ printf %s beta 
+ od -t x1a
0000000  62  65  74  61  20
          b   e   t   a  sp
0000005
trim2 "\rgamma	" | od -t x1a
+ trim2 \rgamma	
+ __trim=\rgamma	
+ printf %s \rgamma	
+ od -t x1a
0000000  0d  67  61  6d  6d  61  09
         cr   g   a   m   m   a  ht
0000007

trim3() {
  _space="$(echo -n '[\b\t\n\v\f\r ]')"
  # remove leading whitespace characters
  __trim="${*##$_space}"
  # remove trailing whitespace characters
  printf "%s" "${__trim%%$_space}"
}

trim3 " alpha" | od -t x1a
+ trim3  alpha
+ od -t x1a
+ echo -n [\b\t\n\v\f\r ]
+ _space=[\b	
\v\f\r ]
+ __trim=alpha
+ printf %s alpha
0000000  61  6c  70  68  61
          a   l   p   h   a
0000005
trim3 "beta " | od -t x1a
+ trim3 beta 
+ od -t x1a
+ echo -n [\b\t\n\v\f\r ]
+ _space=[\b	
\v\f\r ]
+ __trim=beta 
+ printf %s beta
0000000  62  65  74  61
          b   e   t   a
0000004
trim3 "\rgamma	" | od -t x1a
+ trim3 \rgamma	
+ od -t x1a
+ echo -n [\b\t\n\v\f\r ]
+ _space=[\b	
\v\f\r ]
+ __trim=gamma	
+ printf %s gamma
0000000  67  61  6d  6d  61
          g   a   m   m   a
0000005


             reply	other threads:[~2023-02-08  5:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08  5:14 Brian Inglis [this message]
2023-02-08  8:43 ` dash 0.5.12 parameter expansion using classes not working Harald van Dijk
2023-02-08 13:56   ` Brian Inglis

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=12629edc-ec41-ca2a-968b-3be7de2743ae@Shaw.ca \
    --to=brian.inglis@shaw.ca \
    --cc=Brian.Inglis@SystematicSW.ab.ca \
    --cc=dash@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 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 read-only IMAP folder(s) and NNTP newsgroup(s).