[plug] strncmp in shell
Russell Steicke
r.steicke at bom.gov.au
Mon Jan 19 16:06:21 WST 2004
On Mon, Jan 19, 2004 at 03:31:33PM +0800, James Devenish wrote:
...
> But I didn't think you were testing for the behaviour of strncmp (since
> the 'variable' portion of the string is left of the first slash, not to
> its right). For example, the following strings:
>
> one, on, onex, oneone
>
> used with strncmp(...,"one",3) will produce:
>
> equal, not equal, equal, equal
>
> Yet, checking for the empty string after ${FOO/one/} produces these
> corresponding results:
>
> true, false, false, false
I stand corrected. What I wrote was closer to strcmp() than strncmp().
> I suspect the ${...:0:3} = "one" or $... == one* syntaxes would work,
> though.
Yes, one of these or similar syntaxes (there are a few) would probably
work.
--
Russell Steicke
-- Fortune says:
Every young man should have a hobby: learning how to handle money is
the best one.
-- Jack Hurley
More information about the plug
mailing list