Skip to content

Commit

Permalink
Updated README.md => Fixed infite Loop from Windows console startup s…
Browse files Browse the repository at this point in the history
…cript (#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.
  • Loading branch information
ukamp authored May 24, 2024
1 parent a5a497b commit 990f3d0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 990f3d0

Please sign in to comment.