git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.37k stars 2.54k forks source link

Problem with "until" statement in Bash script running on Windows... #4613

Closed htartisan closed 1 year ago

htartisan commented 1 year ago

echo "Waiting for fastbootd over TCP from Recovery, pinging $1"

until $(ping -c1 $1 &>/dev/null); do :; done

Setup

$ git --version --build-options

git version 2.41.0.windows.1
cpu: x86_64
built from commit: ff94e79c4724635915dbb3d4ba38f6bb91528260
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon

Windows 11 64 bit

$ cmd.exe /c ver

Microsoft Windows [Version 10.0.22621.2283]
(c) Microsoft Corporation. All rights reserved.

defaults

# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

*type "C:\Program Files\Git\etc\install-options.txt"
Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: CmdTools
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Enabled
Enable FSMonitor: Enabled

Details

Bash

#echo "Waiting for fastbootd over TCP from Recovery, pinging $1"
until $(ping -c1 $1 &>/dev/null); do :; done

The script should pause at the "unitl" statement, waiting for the "ping" to succeed, and then proceed with the rest of the script/

The script hangs at the "until" statement indefinitly

rimrul commented 1 year ago

$(ping -c1 $1 &>/dev/null)

I don't think we ship a ping.exe, so that's probably Microsoft ping, so you'd need something like

$(ping //n 1 $1 &>/dev/null)
dscho commented 1 year ago

I'll assume that the problem was the expectation that Windows' ping.exe supports the same command-line arguments as Linux' ping.