Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Converting QString to a quoted shell argument.

Converting QString to a quoted shell argument.

Scheduled Pinned Locked Moved Unsolved Qt 6
qt6linuxqstring
3 Posts 3 Posters 421 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Basile_Starynkevitch
    wrote on 8 Mar 2024, 13:25 last edited by Basile_Starynkevitch 3 Aug 2024, 13:38
    #1

    Hello all

    For the RefPerSys inference engine project (GPLv3+, for Linux only) on https://github.com/RefPerSys/RefPerSys/ we are developing a Qt6 graphical interface (GPLv3+) on https://github.com/bstarynk/misc-basile/blob/master/q6refpersys.cc

    The q6refpersys program (a Qt6 interface) will communicate with the RefPerSys inference engine thru fifos or sockets (probably using some JSONRPC protocol)

    We need to convert a QString to some shell-quoted thing. GTK provides the https://docs.gtk.org/glib/func.shell_quote.html and we need the Qt6 equivalent of it. This is useful for displaying literal strings and for debugging messages.

    Also usefu to convert QString into JSON textual representation of it

    Thanks for reading.

    Regards from near Paris in France
    Basile Starynkevitch

    Basile Starynkevitch <basile@starynkevitch.net>
    (only mine opinions / les opinions sont miennes uniquement)
    92340 Bourg-la-Reine, France
    web page: starynkevitch.net/Basile/
    See/voir: https://github.com/RefPerSys/RefPerSys

    C J 2 Replies Last reply 8 Mar 2024, 13:35
    0
    • B Basile_Starynkevitch
      8 Mar 2024, 13:25

      Hello all

      For the RefPerSys inference engine project (GPLv3+, for Linux only) on https://github.com/RefPerSys/RefPerSys/ we are developing a Qt6 graphical interface (GPLv3+) on https://github.com/bstarynk/misc-basile/blob/master/q6refpersys.cc

      The q6refpersys program (a Qt6 interface) will communicate with the RefPerSys inference engine thru fifos or sockets (probably using some JSONRPC protocol)

      We need to convert a QString to some shell-quoted thing. GTK provides the https://docs.gtk.org/glib/func.shell_quote.html and we need the Qt6 equivalent of it. This is useful for displaying literal strings and for debugging messages.

      Also usefu to convert QString into JSON textual representation of it

      Thanks for reading.

      Regards from near Paris in France
      Basile Starynkevitch

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 8 Mar 2024, 13:35 last edited by
      #2

      I'm not aware of such a function in Qt. And I don't see why you would need it. QProcess is doing the correct things with the arguments passed.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • B Basile_Starynkevitch
        8 Mar 2024, 13:25

        Hello all

        For the RefPerSys inference engine project (GPLv3+, for Linux only) on https://github.com/RefPerSys/RefPerSys/ we are developing a Qt6 graphical interface (GPLv3+) on https://github.com/bstarynk/misc-basile/blob/master/q6refpersys.cc

        The q6refpersys program (a Qt6 interface) will communicate with the RefPerSys inference engine thru fifos or sockets (probably using some JSONRPC protocol)

        We need to convert a QString to some shell-quoted thing. GTK provides the https://docs.gtk.org/glib/func.shell_quote.html and we need the Qt6 equivalent of it. This is useful for displaying literal strings and for debugging messages.

        Also usefu to convert QString into JSON textual representation of it

        Thanks for reading.

        Regards from near Paris in France
        Basile Starynkevitch

        J Offline
        J Offline
        JonB
        wrote on 8 Mar 2024, 13:50 last edited by JonB 3 Aug 2024, 13:58
        #3

        @Basile_Starynkevitch
        I don't know what your command is or how you are presently sending it to QProcess as you do not show these.

        You can normally leave the correct quoting to QProcess with an argument list. If, for some reason, you have a string and want to split it into arguments for QProcess you can use QStringList QProcess::splitCommand(QStringView command). Also void QProcess::startCommand(const QString &command, QIODeviceBase::OpenMode mode = ReadWrite) presumably uses that internally.

        Note however that you reference https://docs.gtk.org/glib/func.shell_quote.html and that says

        Quotes a string so that the shell (/bin/sh) will interpret the quoted string to mean unquoted_string.

        Quoting to a shell like /bin/sh can have its own rules. For example, echo '$HOME' and echo "$HOME" behave differently. I don't know how/whether you deal with that. And your GLib shell_quote ignores this.

        1 Reply Last reply
        0

        1/3

        8 Mar 2024, 13:25

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved