Use -print-last-dir option for lfcd.cmd#1444
Conversation
joelim-work
left a comment
There was a problem hiding this comment.
Thanks for working on the lfcd.cmd script.
Just out of curiosity, shouldn't you be using exit /b if you want to prevent the script from exiting the console? I tried exit 0 just by itself and it doesn't seem to change anything.
Also, we have been trying to remove the use of temp files ever since the -print-last-dir option was introduced in r31. I was wondering if you would be able to test the following approach instead to see if it works for you:
@echo off
rem Change working dir in cmd.exe to last dir in lf on exit.
rem
rem You need to put this file to a folder in %PATH% variable.
for /f "usebackq tokens=*" %%d in (`lf -print-last-dir %*`) do cd %%d|
@joelim-work works flawlessly 🎉. Updated the PR with your code (if you're interested in merging it) otherwise I would leave it to you, if you intend to have a backwards compatible approach or a separate lfcd for r31
In my first attempt I used |
There was a problem hiding this comment.
if you intend to have a backwards compatible approach or a separate lfcd for r31
In general we only support the latest version. The old version of the script will always be stored in the Git history for users that can't upgrade or don't want to for some reason.
Anyway I will approve this PR, but I will leave it open in case @gokcehan or anyone else wants to review it. I have also updated the PR title.
-print-last-dir option for lfcd.cmd
|
@atahrijouti @joelim-work Looks good, thanks for the patch. I expect older versions to use the |
The current script was existing the console itself rather than just exiting lfcd.cmd.
explicit exit code makes sure we're only exiting lfcd.cmd