#!/bin/bash

function chcp_com() {
  chcp.com "$@" >/dev/null
}

if [ ! -f ~/.local/state/wslu/oemcp ]; then
  wslsys -v > /dev/null 2>&1
fi

chcp_com "$(cat ~/.local/state/wslu/oemcp)"

RESULT=$(powershell.exe -NonInteractive -NoProfile -ExecutionPolicy ByPass -Command "$@" 2> /dev/null)
EXIT_STATUS=$?

chcp_com 65001

echo "${RESULT}"
exit ${EXIT_STATUS}
