On 2004-11-05 11:39, David O'Brien <obrien_at_FreeBSD.org> wrote: > On Mon, Nov 01, 2004 at 09:55:39PM +0200, Giorgos Keramidas wrote: > > On 2004-11-01 19:30, Jilles Tjoelker <jilles_at_stack.nl> wrote: > > > > - vsystem("echo '# Note that BSD's export syntax is \"host-centric\" vs. Sun\'s \"FS-centric\" one.' >> /etc/exports"); > > > > + vsystem("echo '# Note that BSD'"'"'s export syntax is \"host-centric\" vs. Sun'"'"'s \"FS-centric\" one.' >> /etc/exports"); > > foo.c:18: error: syntax error before '"' > foo.c:18: error: stray '\' in program > foo.c:18: error: stray '\' in program > > vsystem("echo '# Note that BSD'\"'\"'s export syntax is \"host-centric\" vs. Sun'\"'\"'s \"FS-centric\" one.' >> /tmp/exports"); > is what it takes to make this work. Exactly! The only way to include a single quote character in an sh(1) command argument that is already quoted using single quotes is to quote the single quote character *outside* of the quoted string. I don't know if this sounds confused or confusing :-/ > > This, or the bash-like syntax of: > > vsystem("echo '# Note that BSD'\\''s export syntax...' >> /etc/exports"); > > NOW! we have a winner. > > Below is the test program. Which form should we go with? As long as the output file created by this contains the proper output text, I don't care which form is used. Pick one that you like better. I'd probably also add a comment above this point to make it more obvious why the funny quote and backslash weirdness is necessary in the C source, but that's another thing...Received on Sat Nov 06 2004 - 05:40:01 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:21 UTC