Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6445

Git Bash not exiting while loop, while bash in ubuntu does [closed]

$
0
0

I got a while loop in a Bash script which looks something like this

#!/bin/bash# do something with kubectl port-forwardwhile ! nc -vz localhost "$port" > /dev/null 2>&1 ; do    # echo sleeping    sleep 0.1done#access ressource on the port-forwarded website

which basically is supposed to be waiting until a kubectl port-forward command has succesfully started.

However, executing the script under Git Bash (I execute via MSYS_NO_PATHCONV=1 bash) leads to an infinite loop, as it never exits the while loop. I installed ncap and the nc command nc -vz localhost $port works on its own fine. Executing with -x shows that it is looping over the nc command which is running successfully.

Executing the same script in Ubuntu WSL, it just works, exits the while loop as intended and continues.


Viewing all articles
Browse latest Browse all 6445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>