Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

To be is to program.


computers / comp.os.linux.misc / Quotes in a bash script

SubjectAuthor
* Quotes in a bash scriptG
+* Re: Quotes in a bash scriptRich
|`* Re: Quotes in a bash scriptG
| +- Re: Quotes in a bash scriptRich
| `* Re: Quotes in a bash scriptJoe Beanfish
|  `* Re: Quotes in a bash scriptG
|   `* Re: Quotes in a bash scriptLew Pitcher
|    `* Re: Quotes in a bash scriptG
|     `* Re: Quotes in a bash script26C.Z969
|      `- Re: Quotes in a bash scriptPopping Mad
`- Re: Quotes in a bash scriptDominik Ałaszewski

1
Quotes in a bash script

<jrcjpgF7igtU1@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8418&group=comp.os.linux.misc#8418

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: g...@nowhere.invalid (G)
Newsgroups: comp.os.linux.misc
Subject: Quotes in a bash script
Date: 20 Oct 2022 09:47:28 GMT
Organization: <Not Here, Not Me>
Lines: 15
Sender: Gip <gip@G15.fritz.box>
Message-ID: <jrcjpgF7igtU1@mid.individual.net>
X-Trace: individual.net qpzQN3K16LGMW3LmVWYK8wf7aZi8OKqtGoPIrUzuFEBZ6JER3W
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:V607Fs5n9zzFuVkJ1G08+f+T21M=
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.19.13-100.fc35.x86_64 (x86_64))
 by: G - Thu, 20 Oct 2022 09:47 UTC

Hi,

I have to run in a bash script a program that requires the string

'TITLE "Average"'

in the command line with exactly that combination of double and single quotes.

Whatever combinations of quotes, escapes and tricks I try the string passed to
the program is wrong and not accepted. Is there a way to write that in a Bash
script in a way that the prog sees exactly that?

Thanks,

G

Re: Quotes in a bash script

<tirebs$b183$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8419&group=comp.os.linux.misc#8419

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.os.linux.misc
Subject: Re: Quotes in a bash script
Date: Thu, 20 Oct 2022 12:19:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <tirebs$b183$1@dont-email.me>
References: <jrcjpgF7igtU1@mid.individual.net>
Injection-Date: Thu, 20 Oct 2022 12:19:08 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="608fb0993fcac0f0f7bc13f304db3072";
logging-data="361731"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Wd5BsX8kbEjVVLEgg4uq1"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:15KATw24k+5g/hCzaf7i2EwOOMc=
 by: Rich - Thu, 20 Oct 2022 12:19 UTC

G <g@nowhere.invalid> wrote:
> Hi,
>
> I have to run in a bash script a program that requires the string
>
> 'TITLE "Average"'
>
> in the command line with exactly that combination of double and
> single quotes.
>
> Whatever combinations of quotes, escapes and tricks I try the string
> passed to the program is wrong and not accepted. Is there a way to
> write that in a Bash script in a way that the prog sees exactly that?

$ cat scr
#!/bin/bash

echo I see: \'TITLE\ \"Average\"\'

$ ./scr
I see: 'TITLE "Average"'

Re: Quotes in a bash script

<jrd88bFak8lU1@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8420&group=comp.os.linux.misc#8420

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: g...@nowhere.invalid (G)
Newsgroups: comp.os.linux.misc
Subject: Re: Quotes in a bash script
Date: 20 Oct 2022 15:36:43 GMT
Organization: <Not Here, Not Me>
Lines: 44
Sender: Gip <gip@G15.fritz.box>
Message-ID: <jrd88bFak8lU1@mid.individual.net>
References: <jrcjpgF7igtU1@mid.individual.net> <tirebs$b183$1@dont-email.me>
X-Trace: individual.net NBkCXe/v9GixvgDxRg2mGgr9ZBafvcISGwvDCgTBvnOXQvVZSy
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:6xBYK0CXbRRw7zk5sNcR2aGP0BQ=
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.19.16-100.fc35.x86_64 (x86_64))
 by: G - Thu, 20 Oct 2022 15:36 UTC

Rich <rich@example.invalid> wrote:
> G <g@nowhere.invalid> wrote:
>> Hi,
>>
>> I have to run in a bash script a program that requires the string
>>
>> 'TITLE "Average"'
>>
>> in the command line with exactly that combination of double and
>> single quotes.
>>
>> Whatever combinations of quotes, escapes and tricks I try the string
>> passed to the program is wrong and not accepted. Is there a way to
>> write that in a Bash script in a way that the prog sees exactly that?
>
> $ cat scr
> #!/bin/bash
>
> echo I see: \'TITLE\ \"Average\"\'
>
> $ ./scr
> I see: 'TITLE "Average"'

Yes, I have tried that: in "echo" it works but in a script command line for
some reason doesn't. If I use "set -x" to debug this is what I get

++ echo ''\''TITLE "Average"'\'''
'TITLE "Average"'
++ PROG ''\''TITLE "Average"'\'''

And it gives an error, it seems that echo accept what it sees but a program
gets something different or is not equipped to accept it.

Even weirder the error is

syntax error: 'TITLE "Average"'

Which is the proper string, Probably reformatted in output or something....
I have no idea if it is possible to have <PROG 'TITLE "Average"'> as the
actual command, as if I use that synatx on the comman line it works.

Thanks for the help.

G

Re: Quotes in a bash script

<tirrld$c6os$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8421&group=comp.os.linux.misc#8421

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.os.linux.misc
Subject: Re: Quotes in a bash script
Date: Thu, 20 Oct 2022 16:06:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <tirrld$c6os$1@dont-email.me>
References: <jrcjpgF7igtU1@mid.individual.net> <tirebs$b183$1@dont-email.me> <jrd88bFak8lU1@mid.individual.net>
Injection-Date: Thu, 20 Oct 2022 16:06:06 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="608fb0993fcac0f0f7bc13f304db3072";
logging-data="400156"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BWwlsC2Vk9R7qCIRgRfcf"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:MTNvmsvzD2WAUvwcq8RYt5wbPHs=
 by: Rich - Thu, 20 Oct 2022 16:06 UTC

G <g@nowhere.invalid> wrote:
> Rich <rich@example.invalid> wrote:
>> G <g@nowhere.invalid> wrote:
>>> Hi,
>>>
>>> I have to run in a bash script a program that requires the string
>>>
>>> 'TITLE "Average"'
>>>
>>> in the command line with exactly that combination of double and
>>> single quotes.
>>>
>>> Whatever combinations of quotes, escapes and tricks I try the string
>>> passed to the program is wrong and not accepted. Is there a way to
>>> write that in a Bash script in a way that the prog sees exactly that?
>>
>> $ cat scr
>> #!/bin/bash
>>
>> echo I see: \'TITLE\ \"Average\"\'
>>
>> $ ./scr
>> I see: 'TITLE "Average"'
>
> Yes, I have tried that: in "echo" it works but in a script command line for
> some reason doesn't. If I use "set -x" to debug this is what I get

Ok, then lets try launching a real program:

$ cat scr
#!/bin/bash

./prog I see: \'TITLE\ \"Average\"\'
$ cat prog
#!/usr/bin/tclsh

puts "my argv is "
set i -1
foreach arg $argv {
puts "argv\[[incr i]\]: |[lindex $argv $i]|"
}

Now, running it:

$ ./scr
my argv is
argv[0]: |I|
argv[1]: |see:|
argv[2]: |'TITLE "Average"'|

Works just fine, in a script file, for this code above, for me. Which
implies something else going wrong for you.

Re: Quotes in a bash script

<tirrve$b81m$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8422&group=comp.os.linux.misc#8422

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: joebeanf...@nospam.duh (Joe Beanfish)
Newsgroups: comp.os.linux.misc
Subject: Re: Quotes in a bash script
Date: Thu, 20 Oct 2022 16:11:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <tirrve$b81m$1@dont-email.me>
References: <jrcjpgF7igtU1@mid.individual.net> <tirebs$b183$1@dont-email.me>
<jrd88bFak8lU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Oct 2022 16:11:26 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="40f798c9e3619b04bb2a043515685b09";
logging-data="368694"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6n1+UUiwqqDUn0u9+R9tZPbj0olA5Wdc="
User-Agent: Pan/0.146 (Hic habitat felicitas; 8107378
git@gitlab.gnome.org:GNOME/pan.git)
Cancel-Lock: sha1:AZMzPKzDvXJfap8rfkFvvTK8tzQ=
 by: Joe Beanfish - Thu, 20 Oct 2022 16:11 UTC

On Thu, 20 Oct 2022 15:36:43 +0000, G wrote:

> Rich <rich@example.invalid> wrote:
>> G <g@nowhere.invalid> wrote:
>>> Hi,
>>>
>>> I have to run in a bash script a program that requires the string
>>>
>>> 'TITLE "Average"'
>>>
>>> in the command line with exactly that combination of double and
>>> single quotes.
>>>
>>> Whatever combinations of quotes, escapes and tricks I try the string
>>> passed to the program is wrong and not accepted. Is there a way to
>>> write that in a Bash script in a way that the prog sees exactly that?
>>
>> $ cat scr
>> #!/bin/bash
>>
>> echo I see: \'TITLE\ \"Average\"\'
>>
>> $ ./scr
>> I see: 'TITLE "Average"'
>
> Yes, I have tried that: in "echo" it works but in a script command line for
> some reason doesn't. If I use "set -x" to debug this is what I get
>
> ++ echo ''\''TITLE "Average"'\'''
> 'TITLE "Average"'
> ++ PROG ''\''TITLE "Average"'\'''
>
> And it gives an error, it seems that echo accept what it sees but a program
> gets something different or is not equipped to accept it.
>
> Even weirder the error is
>
> syntax error: 'TITLE "Average"'
>
> Which is the proper string, Probably reformatted in output or something....
> I have no idea if it is possible to have <PROG 'TITLE "Average"'> as the
> actual command, as if I use that synatx on the comman line it works.
>
> Thanks for the help.
>
> G

Is "syntax error" from the shell or your program?

Show us the actual complete command line being used. And maybe
a complete short script which demonstrates the problem.

Re: Quotes in a bash script

<jrddjiFbbamU1@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8423&group=comp.os.linux.misc#8423

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: g...@nowhere.invalid (G)
Newsgroups: comp.os.linux.misc
Subject: Re: Quotes in a bash script
Date: 20 Oct 2022 17:08:02 GMT
Organization: <Not Here, Not Me>
Lines: 82
Sender: Gip <gip@G15.fritz.box>
Message-ID: <jrddjiFbbamU1@mid.individual.net>
References: <jrcjpgF7igtU1@mid.individual.net> <tirebs$b183$1@dont-email.me> <jrd88bFak8lU1@mid.individual.net> <tirrve$b81m$1@dont-email.me>
X-Trace: individual.net auKEF6VB5QIce9KG2/Mhfg05NzsnGMyIRZNHslBRbcVImFLwwc
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:wMcYb3qWhHgCck40cgZNAHrtjcQ=
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.19.16-100.fc35.x86_64 (x86_64))
 by: G - Thu, 20 Oct 2022 17:08 UTC

Joe Beanfish <joebeanfish@nospam.duh> wrote:
> On Thu, 20 Oct 2022 15:36:43 +0000, G wrote:
>
>> Rich <rich@example.invalid> wrote:
>>> G <g@nowhere.invalid> wrote:
>>>> Hi,
>>>>
>>>> I have to run in a bash script a program that requires the string
>>>>
>>>> 'TITLE "Average"'
>>>>
>>>> in the command line with exactly that combination of double and
>>>> single quotes.
>>>>
>>>> Whatever combinations of quotes, escapes and tricks I try the string
>>>> passed to the program is wrong and not accepted. Is there a way to
>>>> write that in a Bash script in a way that the prog sees exactly that?
>>>
>>> $ cat scr
>>> #!/bin/bash
>>>
>>> echo I see: \'TITLE\ \"Average\"\'
>>>
>>> $ ./scr
>>> I see: 'TITLE "Average"'
>>
>> Yes, I have tried that: in "echo" it works but in a script command line for
>> some reason doesn't. If I use "set -x" to debug this is what I get
>>
>> ++ echo ''\''TITLE "Average"'\'''
>> 'TITLE "Average"'
>> ++ PROG ''\''TITLE "Average"'\'''
>>
>> And it gives an error, it seems that echo accept what it sees but a program
>> gets something different or is not equipped to accept it.
>>
>> Even weirder the error is
>>
>> syntax error: 'TITLE "Average"'
>>
>> Which is the proper string, Probably reformatted in output or something....
>> I have no idea if it is possible to have <PROG 'TITLE "Average"'> as the
>> actual command, as if I use that synatx on the comman line it works.
>>
>> Thanks for the help.
>>
>> G
>
> Is "syntax error" from the shell or your program?
>
From the program it is the same if I miss a quote.

> Show us the actual complete command line being used. And maybe
> a complete short script which demonstrates the problem.

The program is xmgrace, a plotting prog, from the command line
xmgrace -pexec 'TITLE "Average' -block NSLB3-3d5-11-V.dat -bxy 1:2
plots the proper graph with the title, in the script I have
xmgrace -pexec \'TITLE\ \"Average\"\' -block NSLB3-3d5-11-V.dat -bxy 1:2
And I get the error.
syntax error: 'TITLE "Average"'
with the right string! I tried a small C program "TestIn" with the lines
int main(int argc, char **argv)
{
printf("<%s> <%s>\n",argv[0],argv[1]);
}
and I get from
TestIn 'TITLE "Average"'
<TestIn> <TITLE "Average">
from
TestIn \'TITLE\ \"Average\"\'
<TestIn> <'TITLE "Average"'>
and the same in a script.

I am starting to think that the problem is the plotting prog. I'll try to
contact the author or maybe download the source and see how the input is
processed.

G

Re: Quotes in a bash script

<tisag4$dgg7$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8424&group=comp.os.linux.misc#8424

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.os.linux.misc
Subject: Re: Quotes in a bash script
Date: Thu, 20 Oct 2022 20:19:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 91
Message-ID: <tisag4$dgg7$1@dont-email.me>
References: <jrcjpgF7igtU1@mid.individual.net>
<tirebs$b183$1@dont-email.me> <jrd88bFak8lU1@mid.individual.net>
<tirrve$b81m$1@dont-email.me> <jrddjiFbbamU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Oct 2022 20:19:16 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="212ca0ffaddd271c1a178f4848c9aa03";
logging-data="442887"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+O+mJDSvYt9RRRfr9KEVf7tuagQAE1MMg="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:fZO9LOL/WuXi/5IlHQ/UyUiT9Ho=
 by: Lew Pitcher - Thu, 20 Oct 2022 20:19 UTC

On Thu, 20 Oct 2022 17:08:02 +0000, G wrote:

> Joe Beanfish <joebeanfish@nospam.duh> wrote:
>> On Thu, 20 Oct 2022 15:36:43 +0000, G wrote:
>>
>>> Rich <rich@example.invalid> wrote:
>>>> G <g@nowhere.invalid> wrote:
>>>>> Hi,
>>>>>
>>>>> I have to run in a bash script a program that requires the string
>>>>>
>>>>> 'TITLE "Average"'
>>>>>
>>>>> in the command line with exactly that combination of double and
>>>>> single quotes.
>>>>>
>>>>> Whatever combinations of quotes, escapes and tricks I try the string
>>>>> passed to the program is wrong and not accepted. Is there a way to
>>>>> write that in a Bash script in a way that the prog sees exactly that?
>>>>
>>>> $ cat scr
>>>> #!/bin/bash
>>>>
>>>> echo I see: \'TITLE\ \"Average\"\'
>>>>
>>>> $ ./scr
>>>> I see: 'TITLE "Average"'
>>>
>>> Yes, I have tried that: in "echo" it works but in a script command line for
>>> some reason doesn't. If I use "set -x" to debug this is what I get
>>>
>>> ++ echo ''\''TITLE "Average"'\'''
>>> 'TITLE "Average"'
>>> ++ PROG ''\''TITLE "Average"'\'''
>>>
>>> And it gives an error, it seems that echo accept what it sees but a program
>>> gets something different or is not equipped to accept it.
>>>
>>> Even weirder the error is
>>>
>>> syntax error: 'TITLE "Average"'
>>>
>>> Which is the proper string, Probably reformatted in output or something....
>>> I have no idea if it is possible to have <PROG 'TITLE "Average"'> as the
>>> actual command, as if I use that synatx on the comman line it works.
>>>
>>> Thanks for the help.
>>>
>>> G
>>
>> Is "syntax error" from the shell or your program?
>>
> From the program it is the same if I miss a quote.
>
>> Show us the actual complete command line being used. And maybe
>> a complete short script which demonstrates the problem.
>
> The program is xmgrace, a plotting prog, from the command line
> xmgrace -pexec 'TITLE "Average' -block NSLB3-3d5-11-V.dat -bxy 1:2
> plots the proper graph with the title, in the script I have
> xmgrace -pexec \'TITLE\ \"Average\"\' -block NSLB3-3d5-11-V.dat -bxy 1:2
> And I get the error.
> syntax error: 'TITLE "Average"'
> with the right string!

Yes, of course.

You've escaped the leading and trailing singlequote so they no longer have
special meaning to the shell. That means that the xmgrace program will
receive them verbatum; the argument passed /into/ xmgrace will consist
of a singlequote, followed by the word TITLE, followed by a space, a
doublequote, the word Average, another doublequote and a singlequote.

You can see this if you try using the printf(1) command instead of
the echo command:
16:17 $ printf '[%s]\n' \'TITLE\ \"Average\"\'
['TITLE "Average"']
16:17 $ # xmgrace sees the value between the square brackets

May I suggest
xmgrace -pexec 'TITLE "Average"' -block NSLB3-3d5-11-V.dat -bxy 1:2

The equivalent printf(1) looks like:
16:17 $ printf '[%s]\n' 'TITLE "Average"'
[TITLE "Average"]
16:18 $ # xmgrace sees the value between the square brackets

HTH
--
Lew Pitcher
"In Skills, We Trust"

Re: Quotes in a bash script

<jrf84qFjv6qU1@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8426&group=comp.os.linux.misc#8426

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: g...@nowhere.invalid (G)
Newsgroups: comp.os.linux.misc
Subject: Re: Quotes in a bash script
Date: 21 Oct 2022 09:47:06 GMT
Organization: <Not Here, Not Me>
Lines: 38
Sender: Gip <gip@G15.fritz.box>
Message-ID: <jrf84qFjv6qU1@mid.individual.net>
References: <jrcjpgF7igtU1@mid.individual.net> <tirebs$b183$1@dont-email.me> <jrd88bFak8lU1@mid.individual.net> <tirrve$b81m$1@dont-email.me> <jrddjiFbbamU1@mid.individual.net> <tisag4$dgg7$1@dont-email.me>
X-Trace: individual.net +T1wR0g5z4OEp4kfo1rlKwV8xp/Ab/K7/U5bMIEOVFJY/7fJb/
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:3n+PFfZDaVpbhWjfq19/ZitZeVM=
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.19.16-100.fc35.x86_64 (x86_64))
 by: G - Fri, 21 Oct 2022 09:47 UTC

Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>>
>> The program is xmgrace, a plotting prog, from the command line
>> xmgrace -pexec 'TITLE "Average' -block NSLB3-3d5-11-V.dat -bxy 1:2
>> plots the proper graph with the title, in the script I have
>> xmgrace -pexec \'TITLE\ \"Average\"\' -block NSLB3-3d5-11-V.dat -bxy 1:2
>> And I get the error.
>> syntax error: 'TITLE "Average"'
>> with the right string!
>
> Yes, of course.
>
> You've escaped the leading and trailing singlequote so they no longer have
> special meaning to the shell. That means that the xmgrace program will
> receive them verbatum; the argument passed /into/ xmgrace will consist
> of a singlequote, followed by the word TITLE, followed by a space, a
> doublequote, the word Average, another doublequote and a singlequote.
>
> You can see this if you try using the printf(1) command instead of
> the echo command:
> 16:17 $ printf '[%s]\n' \'TITLE\ \"Average\"\'
> ['TITLE "Average"']
> 16:17 $ # xmgrace sees the value between the square brackets
>
> May I suggest
> xmgrace -pexec 'TITLE "Average"' -block NSLB3-3d5-11-V.dat -bxy 1:2
>
> The equivalent printf(1) looks like:
> 16:17 $ printf '[%s]\n' 'TITLE "Average"'
> [TITLE "Average"]
> 16:18 $ # xmgrace sees the value between the square brackets

Yes that worked I was sure I tried that before (as it is the same as the CLI
version) and didn't work, but maybe it was slightly different

Thanks,

G

Re: Quotes in a bash script

<63527e89$0$473$65785112@news.neostrada.pl>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8427&group=comp.os.linux.misc#8427

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Newsgroups: comp.os.linux.misc
From: Dominik....@gazeta.pl.invalid (Dominik Ałaszewski)
<Dominik.Alaszewski@gazeta.pl.invalid>
Subject: Re: Quotes in a bash script
References: <jrcjpgF7igtU1@mid.individual.net>
Organization: Linux Home Computers
User-Agent: slrn/1.0.3 (Linux)
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Date: 21 Oct 2022 11:12:09 GMT
Lines: 31
Message-ID: <63527e89$0$473$65785112@news.neostrada.pl>
NNTP-Posting-Host: 85.255.244.21
X-Trace: 1666350729 unt-rea-a-02.news.neostrada.pl 473 85.255.244.21:49672
X-Complaints-To: abuse@news.neostrada.pl
X-Received-Bytes: 1595
 by: Dominik Ałaszewski - Fri, 21 Oct 2022 11:12 UTC

Dnia 20.10.2022 G <g@nowhere.invalid> wrote:

> Whatever combinations of quotes, escapes and tricks I try the string passed to
> the program is wrong and not accepted. Is there a way to write that in a Bash
> script in a way that the prog sees exactly that?

In such cases I usually use quotes in sequence, like this:

cat ./check.sh
#/bin/bash
# we want to achieve this: 'TITLE "Average"'
string="'TITLE"
string=$string' "Average"'
string=$string"'"
echo $string
../program.sh $string

and this program.sh
#!/bin/bash
echo $@

and the result:

../check.sh
'TITLE "Average"'
'TITLE "Average"'

I don't know, however, if this is the right approach :-)

--
Dominik Ałaszewski

Re: Quotes in a bash script

<U4OcnfHhO45HNeD-nZ2dnZfqn_ednZ2d@earthlink.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=8934&group=comp.os.linux.misc#8934

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 23 Nov 2022 05:00:10 +0000
Subject: Re: Quotes in a bash script
Newsgroups: comp.os.linux.misc
References: <jrcjpgF7igtU1@mid.individual.net> <tirebs$b183$1@dont-email.me>
<jrd88bFak8lU1@mid.individual.net> <tirrve$b81m$1@dont-email.me>
<jrddjiFbbamU1@mid.individual.net> <tisag4$dgg7$1@dont-email.me>
<jrf84qFjv6qU1@mid.individual.net>
From: 26C.Z...@noaada.net (26C.Z969)
Date: Wed, 23 Nov 2022 00:00:09 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <jrf84qFjv6qU1@mid.individual.net>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Message-ID: <U4OcnfHhO45HNeD-nZ2dnZfqn_ednZ2d@earthlink.com>
Lines: 55
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 68.222.41.46
X-Trace: sv3-wvR09B1gZ+rEKs6KskelD+6v2SJz5ZxGVXVOXA8WWpubEFJIltUBNPQ69/iunUfJAnxdV/6OAzpUZ5h!7VwXg9hvvJreC/LNrfg1C5afHxZpKkfdxFdYBHpzTP1OeB7sOVh7c/qmVa0yXjpBS/FflBZKpnr3!5xfdnUc5cgbcK0Y8+aw=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: 26C.Z969 - Wed, 23 Nov 2022 05:00 UTC

On 10/21/22 5:47 AM, G wrote:
> Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>>>
>>> The program is xmgrace, a plotting prog, from the command line
>>> xmgrace -pexec 'TITLE "Average' -block NSLB3-3d5-11-V.dat -bxy 1:2
>>> plots the proper graph with the title, in the script I have
>>> xmgrace -pexec \'TITLE\ \"Average\"\' -block NSLB3-3d5-11-V.dat -bxy 1:2
>>> And I get the error.
>>> syntax error: 'TITLE "Average"'
>>> with the right string!
>>
>> Yes, of course.
>>
>> You've escaped the leading and trailing singlequote so they no longer have
>> special meaning to the shell. That means that the xmgrace program will
>> receive them verbatum; the argument passed /into/ xmgrace will consist
>> of a singlequote, followed by the word TITLE, followed by a space, a
>> doublequote, the word Average, another doublequote and a singlequote.
>>
>> You can see this if you try using the printf(1) command instead of
>> the echo command:
>> 16:17 $ printf '[%s]\n' \'TITLE\ \"Average\"\'
>> ['TITLE "Average"']
>> 16:17 $ # xmgrace sees the value between the square brackets
>>
>> May I suggest
>> xmgrace -pexec 'TITLE "Average"' -block NSLB3-3d5-11-V.dat -bxy 1:2
>>
>> The equivalent printf(1) looks like:
>> 16:17 $ printf '[%s]\n' 'TITLE "Average"'
>> [TITLE "Average"]
>> 16:18 $ # xmgrace sees the value between the square brackets
>
> Yes that worked I was sure I tried that before (as it is the same as the CLI
> version) and didn't work, but maybe it was slightly different
>
> Thanks,

Ummmmm ... just to be horrible ..... if you're using a scripting
language, how about Python3 ? All of the abovementioned issues
and a thousand others just melt away ...........

I have programs that write and execute small temporary Python
scripts for utility because some things are just easier in
Python and the libraries are EXTENSIVE.

Now yes, I have lots of bash scripts too ... but there comes
a complexity POINT where Python becomes much better and for
sure more clearly self-documenting. Bash is a MESS - they've
been figuring out how to add features to a crude language
for decades ... and frankly the syntax seems now almost
arbitrary, senseless, cultic. Best thing about bash is its
ubiquity - but these days Python is *everywhere* too.

Just sayin' ........

Re: Quotes in a bash script

<todfg6$6mn$3@reader2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=9354&group=comp.os.linux.misc#9354

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rain...@colition.gov (Popping Mad)
Newsgroups: comp.os.linux.misc
Subject: Re: Quotes in a bash script
Date: Mon, 26 Dec 2022 19:49:43 -0500
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <todfg6$6mn$3@reader2.panix.com>
References: <jrcjpgF7igtU1@mid.individual.net> <tirebs$b183$1@dont-email.me>
<jrd88bFak8lU1@mid.individual.net> <tirrve$b81m$1@dont-email.me>
<jrddjiFbbamU1@mid.individual.net> <tisag4$dgg7$1@dont-email.me>
<jrf84qFjv6qU1@mid.individual.net>
<U4OcnfHhO45HNeD-nZ2dnZfqn_ednZ2d@earthlink.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 27 Dec 2022 00:50:14 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="6871"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Content-Language: en-US
In-Reply-To: <U4OcnfHhO45HNeD-nZ2dnZfqn_ednZ2d@earthlink.com>
 by: Popping Mad - Tue, 27 Dec 2022 00:49 UTC

On 11/23/22 00:00, 26C.Z969 wrote:
>> Thanks,
>
>   Ummmmm ... just to be horrible ..... if you're using a scripting
>   language, how about Python3 ?

The topic is BASH - not your favorite language of choice.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor