On my current directory on Windows, I have the following script file simple_script.sh:
#!/bin/bash
echo "hi from simple script"
I wish to run this script on wsl via the powershell command line.
Using the wsl command, I could not find a way to tell wsl to invoke the script code.
The following command works (I think)
wsl bash -c "echo hi from simple script"
However when trying to load the script content into a variable and running it does not work as expected:
$simple_script = Get-Content ./simple_script.sh
wsl bash -c $simple_script
Fails with:
bash: -c: option requires an argument
I tried a few variants. using Get-Content with the -Raw flag seems to make the first word in the string to print (but not the whole string). commands that don't contain '"' characters seems to work sometimes. But I haven't found a consistent way.
A similar looking question doesn't seem to work directly with the wsl, and doesn't seem to run a script file that resides on the Windows file system.