Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(windows): support cmd prompt #4490

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from

Conversation

jukrb0x
Copy link
Contributor

@jukrb0x jukrb0x commented Feb 5, 2024

Description

Support lvim running in Windows Command Prompt (cmd.exe), simply translate lvim.ps1 into lvim.bat and emplace it along with lvim.ps1.

Problem

I didn't find a secure way to set the current user's environment variable in the installer script, using setx could be dangerous:

image

the first time I tried in my cmd it overridden my %PATH%, %PATH% in the cmd includes both the system environment variable and user environment variable, and it somehow happens to truncate to 1024 characters.

so for now user has to manually add an environment variable, I am seeking a secure method to add a user environment variable.

How Has This Been Tested?

  1. add %USERPROFILE%\.local\bin\ to user environment variables
  2. run lvim normally in cmd.exe

image

@jukrb0x jukrb0x marked this pull request as draft February 5, 2024 10:21
@jukrb0x jukrb0x marked this pull request as ready for review February 5, 2024 10:53
@@ -0,0 +1,13 @@
@echo off
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this compare to invoking the powershell script directly (see #1893)?

  • we won't have to maintain two different files
  • arg parsing might be easier without routing to powershell?
@echo off
setlocal enabledelayedexpansion
set args=%*
:: replace problem characters in arguments
set args=%args:`"='%
set args=%args:(=``(%
set args=%args:)=``)%
set invalid=`"='
if !args! == !invalid! ( set args= )
powershell -noprofile -ex unrestricted `"& <lvim_ps1_path> $arg %args%;exit `$lastexitcode`"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants