Subject: B20 - Getting substring functionality to work
From: william walsh <[email-masked]>
To: "[email-masked]'" <[email-masked]>
Date: Tue, 22 Jun 1999 16:38:52 +0100

Hello all,

I am trying to get substring functionality to work for use within GNUMake 
under WindowsNT. cygwin is B20 with the 16Jan99 updated dll.  The bash 
reference says:

${parameter:offset}
${parameter:offset:length}
Expands to up to length characters of parameter, starting at offset. If 
length is omitted, expands to the substring of parameter, starting at the 
character specified by offset. length and offset are arithmetic expressions 
(see section Arithmetic Evaluation). This is referred to as Substring 
Expansion. length must evaluate to a number greater than or equal to zero. 
If offset evaluates to a number less than zero, the value is used as an 
offset from the end of the value of parameter. If parameter is `@', the 
result is length positional parameters beginning at offset. If parameter is 
an array name indexed by `@' or `*', the result is the length members of 
the array beginning with ${parameter[offset]}. Substring indexing is 
zero-based unless the positional parameters are used, in which case the 
indexing starts at 1.

At the bash shell prompt this works:
$ JUNK=BLAHBLAHWOOFWOOF
$ BLAH=${JUNK}
$ echo $BLAH
BLAHBLAHWOOFWOOF

But, any other permutation that adds a colon to the invocation as in:
$ BLAH=${JUNK:2:2}
results in:
Syntax error: Bad substitution

What am I doing wrong?  If I get this to work what happens if I use a 
negative offset that has an absolute value greater than the length of the 
string and/or of the length value?

Regards,
William

--
Want to unsubscribe from this list?
Send a message to [email-masked]