[one-users] tm_common.sh.... typo??

Javier Fontan jfontan at gmail.com
Wed Nov 10 09:51:02 PST 2010


I have made a change in 0eb75b414fe0bc6a829b8b24b0f59b80ed1513e7
(branch bug-389) that sets $SED variable with different values for
linux or anything else. Tell me if that seems correct, I think it is
the most straightforward way to fix the problem.

On Wed, Nov 3, 2010 at 6:30 PM, Tiago Batista <tiagosbatista at gmail.com> wrote:
> During normal operation, the error is not triggered but when I was
> experimenting with zfs-fuse I was able to trigger it.
>
> I will try to demonstrate the problem with an interactive shell...
>
> If i use the following function (note the \+ escaping) it works as
> expected:
>
> function fix_dir_slashes {
>    dirname "$1/file" | sed -e 's/\/\+/\//g';
> }
>
> If however I use the -E switch, for some reason it fails as the
> equivalent gnu switch is -r I think.
>
> $ function fix_dir_slashes { dirname "$1/file" | sed -e 's/\/\+/\//g'; }
> $ fix_dir_slashes /usr/bin//drunk
> /usr/bin/drunk
>
> $ function fix_dir_slashes { dirname "$1/file" | sed -E 's/\/\+/\//g'; }
> $ fix_dir_slashes /usr/bin//drunk
> sed: invalid option -- E
> (...)
>
> I later found out that this is implementation dependent.
>
> The behavior above is from sed 4.1.5 on a scientific linux (rhel based)
> system.
>
> On my gentoo desktop, using sed 4.2.1 I do not get an error, but a
> silent fail to perform the substitution (unless I remove the \+
> escaping, efectively using the regexp from the file):
>
> $ function fix_dir_slashes { dirname "$1/file" | sed -E 's/\/\+/\//g'; }
> $ fix_dir_slashes /usr/bin//drunk
> /usr/bin//drunk
>
> $ function fix_dir_slashes { dirname "$1/file" | sed -E 's/\/+/\//g'; }
> $ fix_dir_slashes /usr/bin//drunk
> /usr/bin/drunk
>
> $ function fix_dir_slashes { dirname "$1/file" | sed -e 's/\/\+/\//g'; }
> $ fix_dir_slashes /usr/bin//drunk
> /usr/bin/drunk
>
>
> At the moment this does not qualify as a bug for me, as all the linux
> systems I know do not fail when paths with multiple slashes are used,
> and the problem with the -E was never triggered with the default tm_nfs
> scripts.
>
> After searching some more and comparing the bsd and the gnu versions of
> sed, I think I may have a solution that works on both platforms (in fact
> the one above!) As I do not see the need for extended regular
> expressions to perform such a simple replacement when escaping the +
> char would solve it...
>
> While at it, I propose that the usage of the $SED variable set above,
> therefore defining the function as:
>
> function fix_dir_slashes { dirname "$1/file" | $SED -e 's/\/\+/\//g'; }
>
> Can you try this on BSD sed as I do not have a BSD shell at the moment?
>
> Tiago
>
> On Wed, Nov 3, 2010 at 4:09 PM, Javier Fontan <jfontan at gmail.com> wrote:
>> Hello,
>>
>> We are using -E as BSD version needs that parameter for this regexp to
>> work and in our tests was working also on linux. Can you tell us what
>> is the error. Is it sed that does not recognize that command or does
>> not perform the intended task?
>>
>> Bye
>>
>> On Mon, Oct 25, 2010 at 3:30 PM, Tiago Batista <tiagosbatista at gmail.com> wrote:
>>> Hello all
>>>
>>> From tm_common.sh:
>>>
>>> # Takes out uneeded slashes. Repeated and final directory slashes:
>>> # /some//path///somewhere/ -> /some/path/somewhere
>>> function fix_dir_slashes
>>> {
>>>    dirname "$1/file" | sed -E 's/\/+/\//g'
>>> }
>>>
>>>
>>> Should this be (notice the sed argument)?
>>>
>>> # Takes out uneeded slashes. Repeated and final directory slashes:
>>> # /some//path///somewhere/ -> /some/path/somewhere
>>> function fix_dir_slashes
>>> {
>>>    dirname "$1/file" | sed -e 's/\/+/\//g'
>>> }
>>>
>>>
>>> I have looked for it, but found no documentation on the -E argument.
>>>
>>> Note that with the tm_nfs drivers this is not an issue (i think...),
>>> but for some reason, when building transfer driver similar to that
>>> found in http://mperedim.wordpress.com/2010/09/26/opennebula-zfs-and-xen-%E2%80%93-part-2-instant-cloning/
>>> this becomes visible as I do call this code...
>>>
>>> Tiago
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opennebula.org
>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>
>>
>>
>>
>> --
>> Javier Fontan, Grid & Virtualization Technology Engineer/Researcher
>> DSA Research Group: http://dsa-research.org
>> Globus GridWay Metascheduler: http://www.GridWay.org
>> OpenNebula Virtual Infrastructure Engine: http://www.OpenNebula.org
>>
>



-- 
Javier Fontan, Grid & Virtualization Technology Engineer/Researcher
DSA Research Group: http://dsa-research.org
Globus GridWay Metascheduler: http://www.GridWay.org
OpenNebula Virtual Infrastructure Engine: http://www.OpenNebula.org


More information about the Users mailing list