Skip to content

Commit 4842174

Browse files
Update all setup scripts to require single key press and only accept Y/y/Enter
Co-authored-by: waldekmastykarz <[email protected]>
1 parent 697d821 commit 4842174

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

scripts/setup-beta.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ Write-Host "4. Configure Dev Proxy and its files as executable (Linux and macOS
1818
Write-Host "5. Configure new version notifications for the beta channel"
1919
Write-Host "6. Add the devproxy-beta directory to your PATH environment variable in `$PROFILE.CurrentUserAllHosts"
2020
Write-Host ""
21-
$response = Read-Host "Continue (Y/n)?"
21+
Write-Host "Continue (Y/n)? " -NoNewline
22+
$key = [Console]::ReadKey($true)
23+
$response = $key.KeyChar
2224

23-
if ($response -in @('n', 'N')) {
24-
Write-Host "Exiting"
25+
if ($response -notin @('Y', 'y', "`r")) {
26+
Write-Host "`nExiting"
2527
exit 1
2628
}
2729

scripts/setup-beta.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@ echo ""
2121

2222
if [ -t 0 ]; then
2323
# Terminal is interactive, prompt the user
24-
read -p "Continue (Y/n)? " -r response
24+
read -p "Continue (Y/n)? " -n1 -r response
25+
if [[ "$response" != "" && "$response" != [yY] && "$response" != $'\n' ]]; then
26+
echo -e "\nExiting"
27+
exit 1
28+
fi
2529
else
2630
# Not interactive
2731
response='y'
2832
fi
2933

30-
if [[ "$response" != "" && "$response" != [yY] ]]; then
31-
echo -e "\nExiting"
32-
exit 1
33-
fi
34-
3534
if [ -t 0 ]; then
3635
echo -e "\n"
3736
fi

scripts/setup.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ Write-Host "3. Unzip the release in the devproxy directory"
1717
Write-Host "4. Configure devproxy and its files as executable (Linux and macOS only)"
1818
Write-Host "5. Add the devproxy directory to your PATH environment variable in `$PROFILE.CurrentUserAllHosts"
1919
Write-Host ""
20-
$response = Read-Host "Continue (Y/n)?"
20+
Write-Host "Continue (Y/n)? " -NoNewline
21+
$key = [Console]::ReadKey($true)
22+
$response = $key.KeyChar
2123

22-
if ($response -in @('n', 'N')) {
23-
Write-Host "Exiting"
24+
if ($response -notin @('Y', 'y', "`r")) {
25+
Write-Host "`nExiting"
2426
exit 1
2527
}
2628

scripts/setup.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ echo ""
2020

2121
if [ -t 0 ]; then
2222
# Terminal is interactive, prompt the user
23-
read -p "Continue (Y/n)? " -r response
23+
read -p "Continue (Y/n)? " -n1 -r response
24+
if [[ "$response" != "" && "$response" != [yY] && "$response" != $'\n' ]]; then
25+
echo -e "\nExiting"
26+
exit 1
27+
fi
2428
else
2529
# Not interactive, set a default response
2630
response='y'
2731
fi
2832

29-
if [[ "$response" != "" && "$response" != [yY] ]]; then
30-
echo -e "\nExiting"
31-
exit 1
32-
fi
33-
3433
if [ -t 0 ]; then
3534
echo -e "\n"
3635
fi

0 commit comments

Comments
 (0)