Page 1 of 1

getting single quotes from newLISP through the shell

Posted: Fri Oct 06, 2006 9:37 am
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?

Posted: Fri Oct 06, 2006 3:53 pm
by frontera000
this is ugly but :

Code: Select all

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

Posted: Fri Oct 06, 2006 5:17 pm
by cormullion
Great - thanks - it works for me (although it doesn't have elegance!). Still, that's Unix.