Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: G Newsgroups: comp.os.linux.misc Subject: Re: Quotes in a bash script Date: 20 Oct 2022 17:08:02 GMT Organization: Lines: 82 Sender: Gip Message-ID: References: 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)) Xref: csiph.com comp.os.linux.misc:35753 Joe Beanfish wrote: > On Thu, 20 Oct 2022 15:36:43 +0000, G wrote: > >> Rich wrote: >>> G 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 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"' 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