On 03/16/2012 07:18 AM, Paolo Bonzini wrote:
> Il 16/03/2012 13:29, Lee Essen ha scritto:
>> @@ -123,7 +123,7 @@ get_argc()
>> # Get the format string including double quotes for a trace event
>> get_fmt()
>> {
>> - puts "${1#*)}"
This says to call puts with the first argument of get_fmt, except with
the shortest prefix ending in ) omitted. Or are you complaining that
there is a shell treating this as a syntax error?
>> + puts "${1#*}"
This says to omit the shortest prefix that matches the glob '*', but
that is always the empty string, so you might as well write it "$1".
>> }
>>
>
> Eric, can you look at this? Is it a bashism or a Solaris bug?
Solaris /bin/sh lacks support for ${var#pattern}, but POSIX requires it.
If this is using #!/bin/sh, you aren't portable.
>
> I would write it, to be entirely safe, as
>
> local fmt
local is not portable.
> fmt=${1#*\)}
> puts "$fmt"
This looks reasonable, if you were hitting syntax errors on an unquoted
), and if you are sure that you have a POSIX rather than Solaris /bin/sh.
>
> where I'm using the extra variable to avoid the ambiguity of quoting the
> parentheses within quotes; variable assignments are always implicitly
> quoted.
>
> Paolo
>
--
Eric Blake [email protected] +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
