• unterminated

    From James Smith@21:1/5 to All on Mon Aug 16 20:13:56 2021
    Do you see why this command is unterminated?
    $ convert -draw 'text 2,120 "Where: x\'s"'
    I'm trying to build a string for a command and run it from python.
    I can't run it from the shell. :-(

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to James Smith on Mon Aug 16 21:32:13 2021
    James Smith <bjlockie021@gmail.com> writes:
    Do you see why this command is unterminated?
    $ convert -draw 'text 2,120 "Where: x\'s"'
    I'm trying to build a string for a command and run it from python.
    I can't run it from the shell. :-(

    Because you can't escape a single-quote character within a single-quoted string.

    $ echo 'foo\'
    foo\
    $

    If you're using bash, consider using its "ANSI-C Quoting" feature. https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html

    (I'd suggest how to do it, but I'm not 100% sure what string you're
    trying to print.)

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    Working, but not speaking, for Philips
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to bjlockie021@gmail.com on Tue Aug 17 06:48:36 2021
    In article <5bcdfe16-d168-485d-8779-b780c47db963n@googlegroups.com>,
    James Smith <bjlockie021@gmail.com> wrote:
    Do you see why this command is unterminated?
    $ convert -draw 'text 2,120 "Where: x\'s"'
    I'm trying to build a string for a command and run it from python.
    I can't run it from the shell. :-(

    To embed a single quoted inside a single-quoted string in a POSIX-ish
    shell, you need to replace each occurrence of ' with the 5 character
    sequence: '"'"'
    (which looks weird/complicated, until you realize it is just 5 keystrokes
    of alternating quotes).

    So, your example becomes:

    $ convert -draw 'text 2,120 "Where: x'"'"'s"'

    I have various aliases and scripts setup to do this replacement when I need
    it to be done...

    --
    Donald Drumpf claims to be "the least racist person you'll ever meet".

    This would be true if the only other person you've ever met was David Duke.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to James Smith on Tue Aug 17 12:42:29 2021
    On 17.08.2021 05:13, James Smith wrote:
    Do you see why this command is unterminated?
    $ convert -draw 'text 2,120 "Where: x\'s"'
    I'm trying to build a string for a command and run it from python.
    I can't run it from the shell. :-(

    Depending on the quotes it's sometimes helpful to use the other quote
    type as surrounding brace and escape the inner

    convert -draw "text 2,120 \"Where: x's\""

    If (since) it's only a string argument to the convert command it may
    also be possible to use other typographical quotes (Unicode supports
    a lot) in the inner string, so that you don't even need escapes? E.g.

    convert -draw "text 2,120 “Where: x's”"


    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Christian Weisgerber on Tue Aug 17 13:35:42 2021
    Christian Weisgerber <naddy@mips.inka.de> writes:

    On 2021-08-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:

    To embed a single quoted inside a single-quoted string in a POSIX-ish
    shell, you need to replace each occurrence of ' with the 5 character
    sequence: '"'"'

    This one is shorter: '\''

    ... but does not work in a POSIX-ish shell like bash. Does it work in
    any shell?

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Weisgerber@21:1/5 to Kenny McCormack on Tue Aug 17 11:36:18 2021
    On 2021-08-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:

    To embed a single quoted inside a single-quoted string in a POSIX-ish
    shell, you need to replace each occurrence of ' with the 5 character sequence: '"'"'

    This one is shorter: '\''

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Weisgerber@21:1/5 to Ben Bacarisse on Tue Aug 17 14:43:59 2021
    On 2021-08-17, Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:

    To embed a single quoted inside a single-quoted string in a POSIX-ish
    shell, you need to replace each occurrence of ' with the 5 character
    sequence: '"'"'

    This one is shorter: '\''

    ... but does not work in a POSIX-ish shell like bash.

    Of course it does.

    Say you want to print "fool's gold".

    Start with a single-quoted string without the apostrophe:
    $ echo 'fools gold'

    Now split it in two single-quoted strings without intervening space:
    $ echo 'fool''s gold'

    Then add a quoted single quote, i.e., \' between the two parts:
    $ echo 'fool'\''s gold'

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Christian Weisgerber on Tue Aug 17 17:05:11 2021
    Christian Weisgerber <naddy@mips.inka.de> writes:

    On 2021-08-17, Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:

    To embed a single quoted inside a single-quoted string in a POSIX-ish
    shell, you need to replace each occurrence of ' with the 5 character
    sequence: '"'"'

    This one is shorter: '\''

    ... but does not work in a POSIX-ish shell like bash.

    Of course it does.

    I see what you are suggesting. I thought you were suggesting simply
    putting the \ in the quotes. It seems obvious now that you were clearly suggesting replacing the whole five char sequence '"'"' with four '\''.

    My apologies.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)