From 990f3d06cf81091d511ecfc67f23842c2b82ca5f Mon Sep 17 00:00:00 2001 From: Ulf Kamp <49397600+ukamp@users.noreply.github.com> Date: Fri, 24 May 2024 07:21:38 +0200 Subject: [PATCH] Updated README.md => Fixed infite Loop from Windows console startup script (#1124) This startup script does not produce the error "i was unexpected at this time" and also won't freeze the console because of an infite loop => "for /F" will launch a new instance of cmd. --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1f16113..558bedf 100644 --- a/README.md +++ b/README.md @@ -178,16 +178,20 @@ fnm env --use-on-cd | Out-String | Invoke-Expression ```powershell notepad $profile ``` + #### Windows Command Prompt aka Batch aka WinCMD -fnm is also supported but is not entirely covered. [You can set up a startup script](https://superuser.com/a/144348) and append the following line: +fnm is also supported but is not entirely covered. [You can set up a startup script](https://superuser.com/a/144348) and append the following lines: ```batch -FOR /f "tokens=*" %i IN ('fnm env --use-on-cd') DO CALL %i +@echo off +:: for /F will launch a new instance of cmd so we create a guard to prevent an infnite loop +if not defined FNM_AUTORUN_GUARD ( + set "FNM_AUTORUN_GUARD=AutorunGuard" + FOR /f "tokens=*" %%z IN ('fnm env --use-on-cd') DO CALL %%z +) ``` -⚠️ If you get the error `i was unexpected at this time`, please make a .cmd file as suggested by the first step in the Usage with Cmder secton add it's path to the `AutoRun` registry key. - #### Usage with Cmder Usage is very similar to the normal WinCMD install, apart for a few tweaks to allow being called from the cmder startup script. The example **assumes** that the `CMDER_ROOT` environment variable is **set** to the **root directory** of your Cmder installation.