Open mbl-35 opened 1 year ago
Change the connect
method from :
[Int32] connect([string]$name) {
$shellArray = @('/bin/zsh', '/bin/bash', '/bin/sh')
$cmdTxt = (( $shellArray | ForEach-Object { "if [ -x $_ ]; then $_ --login;" } ) -Join " else ") + (" fi;" * $shellArray.Length) + ' exit $?'
return $this.exec($name, @("$($cmdTxt)"))
}
to :
[Int32] connect([string]$name) {
$userShell = & $this.Binary --user root --distribution $name getent passwd $env:USERNAME
$userShell = $userShell.Split(":")[-1]
return $this.exec($name, @("$userShell","--login"))
}
Slower but more flexible...
When the default user shell is fish,
wslctl exec {{wsl-name}}
returns the following error and hangs:should be good to get the default user shell from
/etc/passwd
file ... Somethings like:getent passwd {{username}} | awk -F: '{print $NF}'