in reply to [OT] Windows cmd.exe shell

This is not pretty.
@ECHO OFF FOR /F "delims=" %%i IN ('perl -e "print qq(-v)"') DO set perl_argumen +t=%%i perl %perl_argument%
But it works. See C:\> for /help for the gory details.
D:\ENV>test.bat This is perl 5, version 26, subversion 1 (v5.26.1) built for MSWin32-x +64-multi-thread


holli

You can lead your users to water, but alas, you cannot drown them.

Replies are listed 'Best First'.
Re^2: [OT] Windows cmd.exe shell
by syphilis (Archbishop) on Aug 01, 2019 at 14:18 UTC
    See C:\> for /help for the gory details

    I had googled up some references to "for /f", but decided I didn't really want to go down the path of invoking a batch script. (My batch programming skills are very close to non-existent.)
    Besides, is it really possible to write a batch script that will do the job of running "gcc -o file.exe file.c args" where args is the concatenation of ccopts() and ldopts(), and cannot be hard coded into the batch script ?

    Of course, invoking a script to perform the task is not such a bad idea - but I think I'll make it a script that's at least readable:
    use strict; use warnings; die "Usage: 'perl compile_it.pl filename'" unless @ARGV == 1; my $args = `perl -MExtUtils::Embed -e "ccopts"`; chomp $args; $args .= `perl -MExtUtils::Embed -e "ldopts"`; chomp $args; system "gcc", "-o", "$ARGV[0].exe", "$ARGV[0].c", $args;
    Thanks holli.

    Cheers,
    Rob