https://bugs.kde.org/show_bug.cgi?id=524520

            Bug ID: 524520
           Summary: evaluateScript concatenates print() output with no
                    separator
    Classification: Plasma
           Product: plasmashell
      Version First 6.6.6
       Reported In:
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Scripting
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: 1.0

SUMMARY

The string returned by org.kde.PlasmaShell.evaluateScript joins the output of
successive print() calls with no separator. A script that prints more than one
value comes back as a single run-together string, and there is nothing in it to
say where one value ends and the next begins.

STEPS TO REPRODUCE

    qdbus6 org.kde.plasmashell /PlasmaShell \
        org.kde.PlasmaShell.evaluateScript 'print("one"); print("two");'

OBSERVED RESULT

    onetwo

EXPECTED RESULT

    one
    two

print() terminating a record is what the name implies, and what the equivalent
in every other scripting console does.

ADDITIONAL INFORMATION

The transport is not the problem -- a newline inside a single print() survives
the round trip:

    ... evaluateScript 'print("one\ntwo");'
    one
    two

so print() does not append one.

Why it is worth fixing rather than working around: the failure produces
plausible output rather than obviously broken output. Enumerating screens --

    for (var i = 0; i < screenCount; i++) {
        var g = screenGeometry(i);
        print(i + " " + g.width + "x" + g.height);
    }

returns

    0 3440x14401 2560x1440

on a two-screen desktop. The "1" that opens the second record is glued to the
first record's height, so the first screen reads as 14401 pixels tall and the
second record is missing its index. Every field still looks like a number.
Splitting the result on newlines -- the obvious thing to do, and correct for
single-record scripts—yields one record containing all of them.

The workaround is for the script to emit its own separator, which is fine once
you know. Until you know, it looks like the Plasma API is returning bad values.

Operating System: Ubuntu 26.04 LTS (Kubuntu)
KDE Plasma Version: 6.6.6
KDE Frameworks Version: 6.24.0
Qt Version: 6.10.2
Graphics Platform: Wayland

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to