Ticket #191: issue_191_patch_1_of_1_reee1257336aa.patch

File issue_191_patch_1_of_1_reee1257336aa.patch, 22.0 KB (added by patrik.svestka@…, 6 years ago)

Improving the launcher

  • smalltalk.bat

    # HG changeset patch
    # User Patrik Svestka <patrik.svestka@gmail.com>
    # Date 1521020249 -3600
    #      Wed Mar 14 10:37:29 2018 +0100
    # Branch jv
    # Node ID eee1257336aa317c8f0022d39b88fb6911f18fac
    # Parent  6e703805d17586b10be3c76db22908c37258242f
    Merge with #191 tricky characters for batch file
    
    Fixing stx executable and double quotes - to work with path that has spaces in it
    removing text colors - to speed up execution for non-logging case
    SETLOCAL DISABLEDELAYEDEXPANSION for non-logging case
    removing superfluous messages when logging is not used
    adding %use_color% when no_logging is used considerable speedup
    fixing timer at :time_in_seconds function to start correctly
    adding a comment to note the timer section
    changed version
    In powershell reverted back to: $stx_switch = [environment]::GetEnvironmentVariable("stx_switch")
    Adjusting documentation to fit new reality
    
    diff -r 6e703805d175 -r eee1257336aa smalltalk.bat
    a b  
    5353:: Versions =
    5454:: ==========
    5555:: This script
    56 SET "batch_script_version=1.6.8"
     56SET "batch_script_version=1.7.0"
    5757:: Smalltalk/X
    5858SET "stx_version_default=6.2.6"
    5959:: Do not change following line, $STX_VERSION_DEFAULT serves
    6060:: as placeholder and it's being replaced during installation
    6161:: process (`rake install`)
    62 SET "stx_version=%stx_version_default%"
     62SET "stx_version="%stx_version_default%""
    6363
    6464:: ====================
    6565:: Comments and style =
     
    7070
    7171:: If Microsoft should drop support of :: hack. Change you have to change all :: back to REM
    7272
     73
     74
    7375:: =========================================
    7476:: Batch file accepts following parameters =
    7577:: =========================================
     
    307309:: ============
    308310:: Image name =
    309311:: ============
    310 SET "default_image_name="!stx.image_name:"=!!stx.image_suffix:"=!""
     312SET "default_image_name="!stx.image_name:"=!.!stx.image_suffix:"=!""
    311313
    312314:: ============================
    313315:: Add encoding to the suffix =
     
    676678     ) ELSE (
    677679        SET "selected_executable=stx.exe"
    678680     )
    679     SET "smalltalk_executable="!stx.stx_bin_dir:"=!!selected_executable!""
     681    SET "smalltalk_executable=!stx.stx_bin_dir:"=!!selected_executable!"
    680682) ELSE (
    681683
    682684    SET "message="The executable stx-bin^.com;exe perhaps stx^.com;exe NOT found.""
     
    693695:: ==========================================================================================
    694696SET "temp_stx.image_path=!stx.image_path:"=!!default_image_name:"=!"
    695697
     698:: Running too DEEP IFs a workaround
     699SET "stx.load_default_image=FALSE"
    696700IF "!stx.__binary.start_with_image!"=="TRUE" (
    697701    IF "!stx.__binary.list_available_images!"=="FALSE" (
    698702        IF NOT EXIST "!temp_stx.image_path!" (
    699             REM TOO DEEP MUST FIX
    700             REM CALL :colorEcho stx.stdout_cmd_warning "[WARN] The default image: !stx.image_path:"=!!default_image_name:"=! was not found."
    701             REM CALL :colorEcho stx.stdout_cmd_warning "[WARN] No image will loaded. If you want to load from image fix your path or image name."
    702             ECHO:
    703             SET "stx.__binary.start_with_image=FALSE"
     703            SET "stx.load_default_image=TRUE"
    704704        )
    705705    )
    706706)
     707IF "!stx.load_default_image!"=="TRUE" (
     708    CALL :printInColor !stx.stdout_WarningBackgroundColor! !stx.stdout_WarningForegroundColor! "[WARN] The default image: !stx.image_path:"=!!default_image_name:"=! was not found."
     709    CALL :printInColor !stx.stdout_WarningBackgroundColor! !stx.stdout_WarningForegroundColor! "[WARN] No image will loaded. If you want to load from image fix your path or image name."
     710)
     711
    707712
    708713:: clearing temp variable
    709714SET "temp_stx.image_path="
     
    711716:: ===============================================================================
    712717:: Checking existence of logging directory, if not found all logging is disabled =
    713718:: ===============================================================================
    714 IF NOT EXIST "!stx.log_directory!" (
    715     CALL :print_message !use_color! !stx.stdout_WarningBackgroundColor! !stx.stdout_WarningForegroundColor! "[WARN] The logging path: !stx.log_directory! NOT found." "[WARN] Logging will be DISABLED."
    716     ECHO:
    717     SET "stx.__binary.start_with_image=FALSE"
    718     SET "stx.__binary.append_to_log=FALSE"
     719IF "!stx.__binary.record_log_file!"=="TRUE" (
     720    IF NOT EXIST "!stx.log_directory!" (
     721        CALL :print_message !use_color! !stx.stdout_WarningBackgroundColor! !stx.stdout_WarningForegroundColor! "[WARN] The logging path: !stx.log_directory! NOT found." "[WARN] Logging will be DISABLED."
     722        ECHO:
     723        SET "stx.__binary.start_with_image=FALSE"
     724        SET "stx.__binary.append_to_log=FALSE"
     725    )
    719726)
    720727
    721728:: ================================================================
    722729:: Checking existence of log file if not found append is disabled =
    723730:: ================================================================
    724 IF NOT EXIST "!log_filename!" (
    725     CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] No log file found turning off the append mode."
    726     ECHO:
    727     SET "stx.__binary.append_to_log=FALSE"
     731IF "!stx.__binary.record_log_file!"=="TRUE" (
     732    IF NOT EXIST "!log_filename!" (
     733        CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] No log file found turning off the append mode."
     734        ECHO:
     735        SET "stx.__binary.append_to_log=FALSE"
     736    )
    728737)
    729738
    730 
    731739:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    732740:: Next section follows
    733741:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    764772    )
    765773)
    766774
    767 
    768 :: =====================================================
    769 :: Adding all parameters available to the %stx_switch% =
    770 :: Making sure previous switches are taken in account  =
    771 :: =====================================================
    772 :: Cycle all command-line switches entered in the shell by the user
    773 :: Encircle all switches (both - and --) by double-quotes
    774 :: Ignore the command-line switches already with double quotes
    775 :: Replace single quotes with double quotes if such switch is found
    776 REM IF "%1" NEQ "" will cause problems if %1 is enclosed in quotes itself.
    777 REM and you must have the extensions turn on
    778 
    779 IF NOT "%~1"=="" (
    780     SET "stx_manual_switch_detected=TRUE"
    781     SET "detect_double_switch=--"
    782     SET "detect_single_switch=-"
    783     SET "detect_double_quote="-"
    784     SET "detect_single_quote='-"
    785 
    786     FOR %%A IN (%*) DO (
    787         SET "temp_string=%%~A"
    788         IF DEFINED stx_switch (
    789             REM Detect if "" around a switch are used and leave the switch alone
    790             IF "!temp_string:~0,2!"=="!detect_double_quote!" (
    791                 SET "stx_switch=!stx_switch! %%A"
    792             REM Detect if '' around a switch are used and convert them to ""
    793             ) ELSE IF "!temp_string:~0,2!"=="!detect_single_quote!" (
    794                 SET "changed_string=!temp_string:'="!"
    795                 SET "stx_switch=!stx_switch! !changed_string!"
    796             REM if -- found encircle it with double quotes
    797             ) ELSE IF "!temp_string:~0,2!"=="!detect_double_switch!" (
    798                 SET stx_switch=!stx_switch! ^"%%~A^"
    799             REM checks a string for "-" if it contains it it will add double-quotes
    800             ) ELSE IF "!temp_string:~0,1!"=="!detect_single_switch!" (
    801                 SET stx_switch=!stx_switch! ^"%%~A^"
    802             ) ELSE (
    803                 SET "stx_switch=!stx_switch! %%A"
    804             )
    805         REM stx_switch is not yet defined - first run
    806         ) ELSE (
    807             REM Detect if "" around a switch are used
    808             IF "!temp_string:~0,2!"=="!detect_double_quote!" (
    809                 SET stx_switch=!stx_switch! %%A
    810             REM Detect if '' around a switch are used and convert them to ""
    811             ) ELSE IF "!temp_string:~0,2!"=="!detect_single_quote!" (
    812                 SET "changed_string=!temp_string:'="!"
    813                 SET "stx_switch=!stx_switch! !changed_string!"
    814             REM All other options
    815             ) ELSE (
    816                 SET stx_switch=^"%%A^"
    817             )
    818         )
    819     )
    820     REM clearing used variables
    821     SET "detect_switch_double="
    822     SET "detect_single_switch="
    823     SET "detect_double_quote="
    824     SET "detect_single_quote="
    825 )
    826 
    827775:: ======================================================
    828776:: Block CMD PowerShell mode from using manual Switches =
    829777:: ======================================================
     
    837785    )
    838786)
    839787
    840 :: =================================
    841 :: Three ways to start Smalltalk/X =
    842 :: =================================
    843 :: TRUE;TRUE   - User will be asked for input; with which image to start
    844 :: TRUE;FALSE  - Stx will start with the default image configured
    845 :: FALSE;FALSE - Quick start - StX will start without an image
    846 IF "!stx.__binary.start_with_image!"=="TRUE" (
    847     IF "!stx.__binary.list_available_images!"=="TRUE" (
    848         REM USER INPUT
    849         CALL :user_menu !stx.image_path! stx.image_name !stx.image_suffix!
    850         CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] Loading selected image !stx.image_name!"
    851         SET "user_selected_image=!stx.image_name!"
    852         IF DEFINED internal_runtime_options (
    853             SET "stx_switch=!stx_switch! !internal_runtime_options! "--image" !user_selected_image!"
    854         ) ELSE (
    855             SET "stx_switch=!stx_switch! "--image" !user_selected_image!"
    856         )
    857         SET "user_selected_image="
    858     ) ELSE (
    859         CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] DEFAULT IMAGE: !stx.image_path:"=!!default_image_name:"=! starts"
    860         IF DEFINED internal_runtime_options (
    861             SET "stx_switch="--image" !default_image_name! !internal_runtime_options! !stx_switch!"
    862         ) ELSE (
    863             SET "stx_switch="--image" !default_image_name! !stx_switch!"
    864         )
    865     )
    866 ) ELSE (
    867     IF "!stx.__binary.stx_quick_start!"=="TRUE" (
    868         IF "!stx_manual_switch_detected!"=="TRUE" (
    869             CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] Manual switch detected - configuration is ignored"
    870             SET "stx_switch= !stx_switch!"
    871         ) ELSE IF DEFINED internal_runtime_options (
    872             SET "stx_switch="--ignoreImage" !stx_switch! !internal_runtime_options! "--quick""
    873         ) ELSE (
    874             SET "stx_switch="--ignoreImage" !stx_switch! "--quick""
    875         )
    876         REM clearing configured values
    877         SET "stx.image_path="
    878         SET "default_image_name="
    879     )
    880 )
    881 
    882788:: =======================================
    883789:: Check if user wants to command prompt =
    884790:: =======================================
     
    925831:: Return back from the log directory
    926832popd
    927833
     834:: =================================
     835:: Three ways to start Smalltalk/X =
     836:: =================================
     837:: TRUE;TRUE   - User will be asked for input; with which image to start
     838:: TRUE;FALSE  - Stx will start with the default image configured
     839:: FALSE;FALSE - Quick start - StX will start without an image
     840IF "!stx.__binary.start_with_image!"=="TRUE" (
     841    IF "!stx.__binary.list_available_images!"=="TRUE" (
     842        REM USER INPUT
     843        CALL :user_menu !stx.image_path! stx.image_name !stx.image_suffix!
     844        CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] Loading selected image !stx.image_name!"
     845        SET "user_selected_image=!stx.image_name!"
     846        IF DEFINED internal_runtime_options (
     847            SET "stx_switch=!stx_switch! !internal_runtime_options! "--image" !user_selected_image!"
     848        ) ELSE (
     849            SET "stx_switch=!stx_switch! "--image" !user_selected_image!"
     850        )
     851        SET "user_selected_image="
     852    ) ELSE (
     853        CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] DEFAULT IMAGE: !stx.image_path:"=!!default_image_name:"=! starts"
     854        IF DEFINED internal_runtime_options (
     855            SET "stx_switch="--image" "!stx.image_path:"=!!default_image_name:"=!" !internal_runtime_options! !stx_switch!"
     856        ) ELSE (
     857            SET "stx_switch="--image" "!stx.image_path:"=!!default_image_name:"=!" !stx_switch!"
     858        )
     859    )
     860) ELSE (
     861    IF "!stx.__binary.stx_quick_start!"=="TRUE" (
     862        IF "!stx_manual_switch_detected!"=="TRUE" (
     863            CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] Manual switch detected - configuration is ignored"
     864            SET "stx_switch= !stx_switch!"
     865        ) ELSE IF DEFINED internal_runtime_options (
     866            SET "stx_switch="--ignoreImage" !stx_switch! !internal_runtime_options! "--quick""
     867        ) ELSE (
     868            SET "stx_switch="--ignoreImage" !stx_switch! "--quick""
     869        )
     870        REM clearing configured values
     871        SET "stx.image_path="
     872        SET "default_image_name="
     873    )
     874)
     875
     876:: =====================================================
     877:: Adding all parameters available to the %stx_switch% =
     878:: Making sure previous switches are taken in account  =
     879:: =====================================================
     880:: Loop via all command-line switches entered by the user
     881
     882:: If logging is used then the execution is done in PowerShell
     883IF NOT "%~1"=="" (
     884    SET "powershell_stx_switch="
     885    SETLOCAL DISABLEDELAYEDEXPANSION
     886
     887    :process_arguments
     888    REM Process all arguments in the order received
     889    SET "user_param=%1"
     890    IF DEFINED user_param (
     891        SET "powershell_stx_switch=%powershell_stx_switch% "%~1""
     892        SHIFT
     893        GOTO:process_arguments
     894    ) ELSE (
     895        REM On the last run add all previous switches
     896        REM SET "powershell_stx_switch=%powershell_stx_switch% %stx_switch%"
     897        SET "stx_switch=%powershell_stx_switch% %stx_switch%"
     898    )
     899)
     900SETLOCAL ENABLEDELAYEDEXPANSION
     901
    928902
    929903:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    930904:: Next section follows
     
    942916    REM -WindowStyle Normal Sets the window style to Normal, Minimized, Maximized or Hidden.
    943917    REM -NoProfile - launches without a profile
    944918    REM -ExecutionPolicy Bypass - does not ask for passwords if used privileged command.
    945     SET exec_command$=CALL !powershell_exec! -WindowStyle Normal -nologo -noninteractive -NoProfile -ExecutionPolicy Bypass -Command "& {!powershell_script_file! -executable '!smalltalk_executable:"=!' -log_file '!stx.log_directory:"=!!log_filename:"=!' -log_file_encoding '!stx.log_file_encoding!' -append_to_log '!stx.__binary.append_to_log!' -cmd_close '!cmd_close!' -PowerShellVersion '!PowerShellVersion!' -cmd_in_powershell '!stx.__binary.cmd_in_powershell!' -stx_manual_switch_detected '!stx_manual_switch_detected!'};"
     919    SET exec_command$=CALL !powershell_exec! -WindowStyle Normal -nologo -noninteractive -NoProfile -ExecutionPolicy Bypass -Command "& {!powershell_script_file! -executable '!smalltalk_executable!' -log_file '!stx.log_directory:"=!!log_filename:"=!' -log_file_encoding '!stx.log_file_encoding!' -append_to_log '!stx.__binary.append_to_log!' -cmd_close '!cmd_close!' -PowerShellVersion '!PowerShellVersion!' -cmd_in_powershell '!stx.__binary.cmd_in_powershell!' -stx_manual_switch_detected '!stx_manual_switch_detected!'};"
    946920) ELSE (
    947     ECHO:
    948     CALL :print_message !use_color! !stx.stdout_WarningBackgroundColor! !stx.stdout_WarningForegroundColor! "[WARN] NO LOGGING"
    949     ECHO:
    950     CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "[INFO] User disabled or limitation applies." "[INFO] Executing: cmd.exe !cmd_close:"=! CALL !smalltalk_executable:"=! !stx_switch!"
    951     SET "exec_command$=cmd.exe !cmd_close! CALL !smalltalk_executable:"=! !stx_switch!"
     921    SETLOCAL DISABLEDELAYEDEXPANSION
     922    IF "!use_color!"=="TRUE" (
     923        ECHO:
     924        CALL :print_message %use_color% %stx.stdout_WarningBackgroundColor% %stx.stdout_WarningForegroundColor% "[WARN] NO LOGGING"
     925        ECHO:
     926        CALL :print_message %use_color% %stx.stdout_VerboseBackgroundColor% %stx.stdout_VerboseForegroundColor% "[INFO] User disabled or limitation applies." "[INFO] Executing: cmd.exe %cmd_close:"=% CALL %smalltalk_executable:"=% %stx_switch%"
     927    ) ELSE (
     928        ECHO:
     929        ECHO "[WARN] NO LOGGING"
     930        ECHO:
     931        ECHO "[INFO] User disabled or limitation applies."
     932        ECHO "[INFO] Executing: cmd.exe %cmd_close:% CALL %smalltalk_executable% %stx_switch%"
     933        ECHO:
     934    )
     935    SET "exec_command$=cmd.exe %cmd_close% CALL %smalltalk_executable% %stx_switch%"
    952936)
    953937
    954938:: ===========
    955939:: Execution =
    956940:: ===========
     941SETLOCAL ENABLEDELAYEDEXPANSION
    957942:: An alternative working too
    958943REM START /B /W !exec_command$!
    959944
     
    11801165ECHO "Select your stx image (sorted from the newest; if files of same then alphabetic order is used):"
    11811166ECHO:
    11821167(FOR /F "delims=" %%A IN ('dir !input_image_path!^*^.!input_image_suffix! /B /O^:-DN 2^>NUL') DO (
    1183     SET "__stx_image_path.%counter_get_answer%=%%~dpnxA"
     1168ECHO %%~nxA
     1169    SET "__stx_image_path.%counter_get_answer%=!input_image_path!%%~nxA"
    11841170    ECHO "[!counter_get_answer!]  => !__stx_image_path.%counter_get_answer%!
    11851171    SET /A "counter_get_answer+=1"
    11861172)) || REM
     
    12061192:: ECHO "DEBUG: strip quotes: .!user_input:"=!.
    12071193SET "user_input=!user_input:"=!"
    12081194
     1195
    12091196:: If you really want to reject the variable with any quotation mark...
    12101197:: FIND /V-  Displays all lines NOT containing the specified string.
    12111198SET user_input | FIND /V """" >NUL
     
    12611248SET "stx_break="
    12621249(FOR /F "delims=" %%A IN ('dir !input_image_path!^*^.!input_image_suffix! /B /O^:-DN 2^>NUL') DO IF NOT DEFINED stx_break (
    12631250    IF "!verified_user_input!"=="!counter_get_file!" (
    1264       SET "__stx_image_path="%%~dpnxA""
     1251      SET "__stx_image_path="!input_image_path!%%~nxA""
    12651252      SET "stx_break=yes"
    12661253    ) ELSE IF "!counter_get_answer!" LSS "!counter_get_file!" (
    12671254      SET "__stx_image_path="Unknown path""
     
    14261413CALL powershell -nologo -noninteractive -NoProfile -ExecutionPolicy Bypass -Command %long_command%
    14271414GOTO :EOF
    14281415
     1416
     1417:: =======
     1418:: Timer =
     1419:: =======
    14291420:time_in_seconds
    14301421FOR /F %%A IN ('wmic os get LocalDateTime ^| find "."') DO (
    14311422    SET "dts=%%A"
     
    15161507ECHO -- object to execute the stx executable.  It brings two benefits:
    15171508ECHO -- a) stdout and stderrr are independent and asynchronous from the executable
    15181509ECHO -- b) all output is recorded correctly into the log file.
     1510ECHO -- b) all output is recorded correctly into the log file.
     1511ECHO -- User can adjust the refresh rate for the asynchronous powershell output via __numeric.start_sleep_in_debug variable
    15191512ECHO:
    15201513ECHO:
    15211514ECHO:
     
    17231716ECHO 5) The .lnk files are tested on Windows 7 SP1 (known to not work on Windows XP, you have to use the batch file directly.)
    17241717ECHO 6) When using CMD PowerShell mode manual (user) switches can not be used.  When used the batch file forces CMD only mode.
    17251718ECHO 7) The launcher can have issues with double-quotes and quotes within - escape them when needed - e.g. use double double quotes to escape
    1726 ECHO 8) Issues with the "!" character to add it you have to use escape ^ character e.g. --eval "Transcript showCR: 'Bang^^^!'."
    1727 ECHO 9) Any switch containing question mark (?) will be ignored - batch file FOR limitation e.g. smalltalk -I --quick --eval "Transcript showCR: 'How are you?'."
    1728 ECHO    The whole "Transcript showCR: 'How are you?'." will be "eaten" by batches FOR statement.
     1719ECHO:
     1720ECHO 8)  Characters ^^^< ^^^& ^^^| ^^^> need to be escaped with triple batch escaping character: ^^^. 
     1721ECHO     Inner, within double or single quotes,  double or single quotes can not be used.
     1722ECHO:
     1723ECHO     Note: Using the multiple tricky characters together within one command can cause the command to fail altogether
     1724ECHO:
     1725ECHO     User input validation is tricky in batch files.  There is no foolproof user validation.
     1726ECHO     You can visit http://www.robvanderwoude.com/battech_inputvalidation_commandline.php for more.
     1727ECHO:
     1728ECHO:
     1729ECHO Examples how to correctly escape tricky characters:
     1730ECHO: a) smalltalk -P "Stdout nextPutLine: '^^^|'"
     1731ECHO: b) smalltalk -P "Stdout nextPutLine: '^^^>'"
     1732ECHO: c) smalltalk -P "Stdout nextPutLine: '^^^&'"
    17291733ECHO:
    17301734ECHO:
    17311735ECHO:
  • smalltalk.ps1

    diff -r 6e703805d175 -r eee1257336aa smalltalk.ps1
    a b  
    1616# StX switches which are build during batch file execution $env:stx_switch
    1717$stx_switch = [environment]::GetEnvironmentVariable("stx_switch")
    1818
     19
    1920# PowerShell version detected during batch file execution  $env:powershell_version_all_functionality
    2021If (![String]::IsNullOrEmpty([environment]::GetEnvironmentVariable("powershell_version_all_functionality"))) {
    2122    $stx_powershell_version = [environment]::GetEnvironmentVariable("powershell_version_all_functionality")
     
    307308                    [System.Object] $sender,
    308309                    [System.Diagnostics.DataReceivedEventArgs] $events
    309310                )
     311
    310312                # Where to log
    311313                $file_log = $Event.MessageData.file_logging
    312314
    313315                ForEach  ($line in $events.data) {
    314316                    Write-Verbose "[stdout]: $line" -Verbose
    315                    
    316317                    # write to the log file
    317318                    $exec_with_logging = @"
    318319Write-Output '[stdout]: $line' | $file_log
    319320"@
    320321                    Invoke-Expression -Command:$exec_with_logging
    321                    
    322322                }
    323323            } -MessageData $passing_variable
    324324            # /Out Listener - stdout