-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.The question is answered.
Description
Posix shell
Posix shells have very helpful -x cli flag. It could be also enabled inside script code with line 'set -x'. It shows commands as they are exactly executed
Example shell code
% cat hello.sh
#!/bin/sh
set -x
msg="world"
echo "hello $msg"
Output
% ./hello.sh
+ msg=world
+ echo hello world
hello world
If there is something unexpected in script, then I can easily copy interesting line to another terminal and run it.
Powershell
My best finding is 'Set-PSDebug -Trace 2' function.
Example powershell code
% cat hello.ps
#!/usr/bin/pwsh
Set-PSDebug -Trace 2;
$msg="world"
write-host "hello $msg"
Output
% ./hello.ps
DEBUG: 5+ >>>> $msg="world"
DEBUG: ! SET $msg = 'world'.
DEBUG: 6+ >>>> write-host "hello $msg"
hello world
Powershell shows lines of source code. It does not evaluate variables values. I would like to see write-host "hello world"
as extra debug message.
Question
Is it possible to see executed lines of script code in powershell? Could it evaluate variables values before printing debug message about executing command? How to do it?
mklement0, bb010g, mike-clark-8192 and yanghanlin
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.The question is answered.