getting single quotes from newLISP through the shell

Q&A's, tips, howto's
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

getting single quotes from newLISP through the shell

Post by cormullion »

Not really a newLISP question, perhaps, but I'm struggling again so your help would be helpful...

Code: Select all

(set 'r (join (map char (sequence 32 127))))
(exec (string {echo '} r {'}))

sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: `echo ' !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~''
I think it's that single quote, which you can't escape inside a single-quoted string, so you can't get it into a string that you can echo or pipe into a command. Is there a way?

frontera000
Posts: 72
Joined: Sun Jun 11, 2006 8:02 pm
Location: berkeley, california
Contact:

Post by frontera000 »

this is ugly but :

Code: Select all

(replace "'" r "\\x27")
(exec (string {echo -e '} r {'}))

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Great - thanks - it works for me (although it doesn't have elegance!). Still, that's Unix.

Locked