NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: PR/57773 CVS commit: src/bin/sh



The following reply was made to PR bin/57773; it has been noted by GNATS.

From: Jarle Greipsland <jarle.greipsland%norid.no@localhost>
To: gnats-bugs%netbsd.org@localhost, kre%netbsd.org@localhost
Cc: 
Subject: Re: PR/57773 CVS commit: src/bin/sh
Date: Wed, 27 Dec 2023 23:44:07 +0100 (CET)

 "Robert Elz" <kre%netbsd.org@localhost> writes:
 >  Fix a bug reported by Jarle Fredrik Greipsland in PR bin/57773,
 >  where a substring expansion where the substring to be removed from
 >  a variable expansion is itself a var expansion where the value
 >  contains one (or more) of sh's CTLxxx chars - the pattern had
 >  CTLESC inserted, the string to be matched against did not.  Fail.
 >  We fix that by always inserting CTLESC in var assign expansions.
 >  See the PR for all the gory details.
 Excellent!
 
 There are however still some gremlins in the code wrt. to the
 escape characters.  The string lengths are not always calculated
 correctly.
 
 ------------------------------------------------------------
 #!/bin/sh
 
 export LC_ALL=C
 
 f() {
     printf 'f->$1 Length of %s: %d\n' "$1" ${#1}
 }
 
 {
     c=$(printf '\202')
     printf '$c Length of %s: %d\n' "$c" ${#c}
 
     f "$c"
 
     set -- "$c"
     printf '$1 Length of %s: %d\n' "$1" ${#1}
 } | vis -o
 
 exit 0
 ----------------------------------------------------------------------
 
 The above code will print lengths as 1, 2 and 2.  And they ought
 to be all one.
 					-jarle
 -- 
 "We do this not because it is easy, but because we thought it would be easy."
 


Home | Main Index | Thread Index | Old Index