2016-07-13 21:45 GMT+08:00 Marc Feeley <feeley@iro.umontreal.ca>:Yes that’s one argument (the avoidance of system exploits through some data that is passed to the shell).
There’s also a portability argument. Shell escaping varies between platforms (Unix/Windows), and also from one shell to another.
Moreover, manual shell escaping has always been a nightmare (how many backslashes to add?) that it is best to avoid it completely by letting the implementation do it automatically. I wouldn’t like a system where the user has to worry about the possibility of arguments containing “$” and “\” and double/single quotes.Ah those are fantastic arguments for it to be like it is now too.So for your use-case I would suggest:
> (define (pkg-config-lib name)
(call-with-input-process
(list path: "pkg-config" arguments: (list "--libs" name))
read-line))
> (pkg-config-lib "zlib")
"-lz"
> (compile-file "test.scm" ld-options: (pkg-config-lib "libjpeg"))Yup perfect.Thanks!
Best regards
Dear Adam,
> What made me run into the question of the cc- and ld-options argument
> to compile-file should work, was that I for the first time ever needed
> to link to a library that has different names on different platforms.
I am sorry, but I am not sure I fully understand your request. Thus far I have only encountered one package which has different linking names for different platforms: libpcap (which is libpcap.a on most platforms other than Win32, where it is libwpcap.a). My solution was to copy the library file to make it match, which solved this for me. - I don't know enough about Gambit-internals to properly comment on a more sensible approach but feel free to mention my comment when it does get discussed on the Gambit mailing list.