Comments (9)
This isn't related to Clink, it's just bugs in the batch script.
- See documentation for setlocal.
endlocal
happens automatically at the end of the batch script, if there isn't an explicitendlocal
in the script.- You could use the idiom
endlocal & set PATH=%PATH%
to end thesetlocal
scope, but also keep the value of %PATH%. - The idiom relies on the fact that CMD expands environment variables in the whole line before running any part of the line, so the
%PATH%
is expanded before theendlocal
runs, but theset PATH={expanded value of %PATH%}
runs after theendlocal
.
- The
set PATH
at the end isn't reached becauseclink
is a batch script; it'sclink.bat
.- The Clink executables are
clink_x86.exe
andclink_x64.exe
, and theclink.bat
script picks the right one to run based on whether the currentcmd.exe
is 32-bit or 64-bit. - Invoking a batch script from inside another batch script does not return to the original batch script. To return to the original script, use the call command.
call clink inject
. - Adding the
call
keyword makes the finalset PATH
show that the condabin directory is present, which demonstrates that the problems the script is encountering have nothing to do with Clink.
- The Clink executables are
from clink.
Have you found the Usage section at the beginning of the documentation?
I think it answers the question.
Do you have questions about it?
clink inject --help
from clink.
it works perfectly find using just clink inject. maybe I need to slow down and read more docs. thank you for your fast reply.
from clink.
When I set path;
@echo off
setlocal enabledelayedexpansion
rem Define the directory to add to the PATH
set "directory=C:\Users\dhorner\anaconda3\condabin"
rem Check if the directory is already in the PATH
echo %PATH% | findstr /i /c:"%directory%" >nul
if errorlevel 1 (
rem If not found, add the directory to the PATH
set PATH
set "PATH=%PATH%;%directory%"
set PATH
) else (
rem If found, do nothing
echo Directory already exists in PATH.
)
endlocal
@echo off
rem set PATH=%PATH%;C:\Users\dhorner\anaconda3\condabin
clink inject
set PATH
set PATH does not include the variable that was added above the call to inject. if I move the inject above, I lose my subsequent commands and fall into the injected prompt. I will spend more time with the documentation. thank you
from clink.
Because of the endlocal
which reverts all changes to the environment.
It's just a CMD scripting mistake and isn't related to Clink. 🙂
from clink.
I removed the endlocal. Thank you! However, I am still finding that the path is not coming thru.
@echo off
setlocal enabledelayedexpansion
rem Define the directory to add to the PATH
set "directory=C:\Users\dhorner\anaconda3\condabin"
rem Check if the directory is already in the PATH
echo %PATH% | findstr /i /c:"%directory%" >nul
if errorlevel 1 (
rem If not found, add the directory to the PATH
set PATH <-- I verify its not there
set "PATH=%PATH%;%directory%"
set PATH <-- I verify its there.
) else (
rem If found, do nothing
echo Directory already exists in PATH.
)
clink inject
set PATH <-- doesn't run
then when run interactively from the injected prompt; it shows the original path.
from clink.
I didn't mean to suggest it was a bug in clink, just looking for a hand.
The idiom works great! It might be worth a note for others. maybe it's common knowledge.
call clink inject
endlocal & set PATH=%PATH%
I appreciate your thoughtful response. Thank you.
from clink.
I didn't mean to suggest it was a bug in clink, just looking for a hand.
Starting a Discussion is more clear that it's just a request for general help that might be unrelated to the forum.
The idiom works great! It might be worth a note for others. maybe it's common knowledge.
Since it has nothing to do with Clink, it's hard to imagine where to mention it in the Clink documentation, and it's unclear how readers would find it when it was relevant to whatever they were doing.
Seems like the note belongs in a different forum, perhaps one about CMD scripting instead of about Clink.
from clink.
Sorry.
from clink.
Related Issues (20)
- How to remove startup messages from CMD and Clink? HOT 6
- CTRL-C does not copy text selected using conhost mouse selection HOT 9
- Incorrect shell type in the window title: `Windows PowerShell` HOT 6
- Excessive clink execution even if `cmd.exe` called without interactive input HOT 18
- Why are commands starting with "history" always excluded from history? HOT 7
- Replace unix path separator on complete HOT 6
- Update fails with Clink 1.6.19 HOT 9
- clink_start.cmd is run twice when clink is installed in %localappdata%\clink HOT 4
- Clink incorrectly shows certain commands as quoted HOT 2
- Error in update.lua Script: Attempt to Index Local 'line' (a Number Value) at Line 106 HOT 2
- the default ocmmand line experience allows wildcard based autocompletion on hitting tab key but after installing clink it doesn't HOT 5
- How can I make argmatchers for the arguments to specific perl scripts? HOT 8
- Incremental tab completion on auto-suggestion HOT 3
- Color brightness in CMD prompt, different between Win11 and Server 2016 HOT 3
- Trouble emulating Ctrl-D as EOF HOT 6
- Not recieving 'a' key is down HOT 3
- How to override autorun for clink? HOT 14
- Wrong cursor position when CD contains non-printable characters HOT 23
- from lua, send command to prompt and run it HOT 4
- color.env_variables option HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clink.