I am trying to understand the following (odd?) behavior on my setup. I am running Windows 10, with WSL.
Here is what I see from my powershell wsl session:
$ ./run.sh
Windows IP Configuration
<cut>
1
with:
$ cat run.sh
#!/bin/bash
mkdir -p dir/1
mkdir -p dir/2
mkdir -p dir/3
var=0
while read i;
do
((var ))
ipconfig.exe
done < <(find dir -type d)
echo $var
If I now comment out the ipconfig.exe
line:
...
#ipconfig.exe
...
Here is now what I get:
$ ./run.sh
4
Why calling a window executable (eg. ipconfig.exe
) seems to interfere with my while
loop) ?
For reference:
$ uname -a
Linux FR-L0002146 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
and
$ bash -version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
CodePudding user response:
Most likely ipconfig.exe
is reading from stdin, so it's sucking up the input from the process substitution. Redirect its input to /dev/null
to prevent this.
while read i;
do
((var ))
ipconfig.exe </dev/null
done < <(find dir -type d)