bug-coreutils
[Top][All Lists]
Advanced

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

Re: Portability issue


From: Paul Eggert
Subject: Re: Portability issue
Date: Sun, 08 Aug 2004 17:17:52 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

DervishD <address@hidden> writes:

>     expr substr "x$string" $tmpindex 1
>
>     If I need to translate this in a pattern matching expression, I
> must calculate the number of 'dots', because I'm not sure if the
> '{N}' syntax (to match exactly '{N}' times) is portable enough.

You're right to worry, I suspect it wouldn't be portable to
sufficiently-ancient hosts (e.g., 4.2BSD).  However, it is standardized
by POSIX 1003.1-1992.  You need backslashes in front of the braces,
though.  E.g.:

expr "X$string" : 'X.\{3\}\(.\)'

outputs the 4th character in "$string" (origin-1).

> (I don't have access to a POSIX standard so I've chosen SUS
> as my standard base).

POSIX is available free of charge on the web, here:

http://www.unix.org/single_unix_specification/

You are supposed to register, but access is free after that.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]