Control: tags 961222 patch

Christoph Biedl wrote...

> Reverting to "#!/bin/bash" yields
> the expected behaviour, too.

So this is something, one I didn't know about:

In bash and dash,

    var=$(something)

works as expected even if that ``something`` contains spaces, like in

    var=$(date '+%F %T')

Things are however different in dash if you're within a function and
want to limit the scope, i.e.

    local var=$(date '+%F %T')

Quite frankly, I haven't checked which shell implementation does not
follow the specification, if any, or if this is just another bashism.
Quoting fixes this, see below

    Christoph

--- /usr/bin/ucf.broken
+++ /usr/bin/ucf.fixed
@@ -82,8 +82,8 @@
     local new_file="$4"
 
     # Note: get_file_metadata not in quotes to ignore "\n" characters
-    local old_file_label=$(get_file_metadata "$old_file")
-    local new_file_label=$(get_file_metadata "$new_file")
+    local old_file_label="$(get_file_metadata "$old_file")"
+    local new_file_label="$(get_file_metadata "$new_file")"
 
     [ -e "$old_file" ] || old_file=/dev/null
     [ -e "$new_file" ] || new_file=/dev/null

Attachment: signature.asc
Description: PGP signature

Reply via email to