Re: Portable Cygwin: Hard-Coded Paths in a Restored Cygwin.bat File?
Jon Turney via Cygwin-apps <[email protected]>
| Newsgroups | gmane.os.cygwin.applications |
|---|---|
| Message-ID | <[email protected]> |
On 05/08/2025 05:56, Brian Inglis via Cygwin-apps wrote: > On 2025-08-04 17:30, Matthew Sheets via Cygwin-apps wrote: >> Are there two different versions of Cygwin.bat that Cygwin Setup could >> create depending on the context in which Cygwin Setup is executed? >> >> If Cygwin setup is being used to create a new installation, the >> installed Cygwin.bat is fairly path independent: >> @echo off >> setlocal enableextensions >> set TERM= >> cd /d "%~dp0bin" && .\bash --login -i >> >> >> However, if Cygwin setup is being executed for an already-existing >> installation and restores a deleted Cygwin.bat, that restored >> Cygwin.bat contains hard-coded paths: >> @echo off >> C: >> chdir C:\Portable\Cygwin\arch-x86_64\bin >> bash --login -i > > I still had one of the latter installed from 2013! > > If you look at one of the base packages: > > $ cygcheck -l base-files > /etc/defaults/Cygwin.bat > ... > /etc/postinstall/base-files-profile.sh > /etc/preremove/base-files-manifest.lst > /etc/preremove/base-files.sh > > it provides defaults and sets them up in the postinstall script driven > by the manifest. > > In our case, the ancient Cygwin.bat was always installed with a hard- > coded path by Cygwin setup and never replaced, by design! > > I just updated it from /etc/defaults/ so it looks like your first version. > > You could also rm /Cygwin.bat and rerun /etc/postinstall/base-files- > profile.sh, possibly with a .done suffix after Setup. > >> For a portable setup, I am intending to remove and wrap Cygwin.bat and >> have _zero_ issue with Cygwin Setup restoring it (I was actually >> hoping Cygwin Setup _did_ restore Cygwin.bat so that any updates to >> Cygwin.bat could be incorporated), but the challenge here is that a >> completely different Cygwin.bat that contains hard-coded paths is >> created upon restoration. Is this file content difference expected? >> Could the `cd /d "%~dp0bin"` syntax be used in both cases (in place of >> the hardcoded paths)? > > It has been and should be since at least 2016, when it was added to > base-files; previously it was installed by Cygwin Setup and never > updated if it existed: > > https://cygwin.com/cgit/cygwin-apps/setup/tree/desktop.cc? > id=bf1d58#n163 > Huh. Well, a patch to setup either to remove that function (since it doesn't seem to serve any useful purpose now), or modernize the batch file it writes would be very welcome.