[libvirt] [PATCH] [TCK] Convert scripts to also run with dash

Justin Clift jclift at redhat.com
Mon Nov 15 19:29:15 UTC 2010

On 16/11/2010, at 6:08 AM, Stefan Berger wrote:
>> Ah - the plot thickens, and the light bulb goes on for me.  It's not
>> just a problem with read, but also with your use of 'echo' to try and
>> replay a just-read string.  'echo' and '\' don't mix.  You have to use
>> printf for any chance of portability.
>> printf %s\\n "\1"
>> printf %s\\n '\1'
> I am surprised that dash doesn't take the opportunity to already extend "\1" or '\1' to char(1) in these cases.  A mystery... :-)
> I'll fix it. Thanks.

We seem to have recurring problems with finding portable commands, that work across everything.

Would use an alternative approach, such as having our own wrapper functions, be more reliable?

(conceptually like this)

function replace_stuff()
  if "$SHELL" = "dash"
    dash specific sed here
  elsif "$SHELL = bash"
    bash specific sed here
    sh fallback sed here

# main code
replace_stuff ("foo" "bar")


More information about the libvir-list mailing list