Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.misc > #35753
| From | G <g@nowhere.invalid> |
|---|---|
| Newsgroups | comp.os.linux.misc |
| Subject | Re: Quotes in a bash script |
| Date | 2022-10-20 17:08 +0000 |
| Organization | <Not Here, Not Me> |
| Message-ID | <jrddjiFbbamU1@mid.individual.net> (permalink) |
| References | <jrcjpgF7igtU1@mid.individual.net> <tirebs$b183$1@dont-email.me> <jrd88bFak8lU1@mid.individual.net> <tirrve$b81m$1@dont-email.me> |
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
Back to comp.os.linux.misc | Previous | Next — Previous in thread | Next in thread | Find similar
Quotes in a bash script G <g@nowhere.invalid> - 2022-10-20 09:47 +0000
Re: Quotes in a bash script Rich <rich@example.invalid> - 2022-10-20 12:19 +0000
Re: Quotes in a bash script G <g@nowhere.invalid> - 2022-10-20 15:36 +0000
Re: Quotes in a bash script Rich <rich@example.invalid> - 2022-10-20 16:06 +0000
Re: Quotes in a bash script Joe Beanfish <joebeanfish@nospam.duh> - 2022-10-20 16:11 +0000
Re: Quotes in a bash script G <g@nowhere.invalid> - 2022-10-20 17:08 +0000
Re: Quotes in a bash script Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-10-20 20:19 +0000
Re: Quotes in a bash script G <g@nowhere.invalid> - 2022-10-21 09:47 +0000
Re: Quotes in a bash script "26C.Z969" <26C.Z969@noaada.net> - 2022-11-23 00:00 -0500
Re: Quotes in a bash script Dominik Ałaszewski <Dominik.Alaszewski@gazeta.pl.invalid> - 2022-10-21 11:12 +0000
csiph-web