[Qgis-user] OSGeo4W Shell with Unix-Style Terminal?

Mike Treglia mtreglia at gmail.com
Thu Jul 7 14:31:26 PDT 2022


Thanks again, Jürgen,

I appreciate the explanation - this is definitely an area where I can often
figure things out, but am still learning and fumbling my way through it a
bit.

So I've added the below to my profile (from the link you've previously
shared), and I can run 'fetchenv /c/OSGeo4W/bin/o4w_env.bat' from my bash
terminal - and it starts the process, but it either is getting hung up, or
is just taking longer than I anticipated - is it something that does take
some time and I just need to let it run, so be patient? Or am I maybe
missing or need to adjust something else?

If I try to suspend the process (ctrl + z) after a few minutes, I get a
message along these lines:
1 [sig] bash 471! sigpacket::process: Suppressing signal 18 to win32
process (pid 5648)

Then, I can kill that process, and then go through those steps (ctrl + z,
followed by killing the process) once more before it'll close out.

Best,
Mike

------ Code added to .profile
fetchenv() {
local IFS
IFS=
local batch=$1
shift

if ! [ -f "$batch" ]; then
echo "$batch not found"
return 1
fi

local d=$(mktemp -d /tmp/fetchenv.XXXXXXXXXX)
cmd /c set >$d/srcenv || true
cmd /c call $(cygpath -w $batch) "$@" \>nul 2\>\&1 \& set >$d/dstenv || true
sleep 2
cat <<EOF >$d/envdiff
/^+++/d;
/^[^+]/d;
s/^+//;
# s/\\\\/\\\\\\\\/g;
/^PATH=/ {
s/\\\\/\\//g;
s#\\([=;]\\)\\([a-zA-Z]\\):#\\1/cygdrive/\\2#g;
s/;/:/g;
}
s/;/\\\\;/g;
s/^/export /;
s/=/='/;
s/\\\\r//g;
s/\r$/'/;
EOF
diff -u $d/srcenv $d/dstenv | sed -f $d/envdiff >$d/diffenv
. $d/diffenv
PATH=$PATH:/bin:/usr/bin:$(cygpath --sysdir):$(cygpath --windir)
rm -fr $d || true
}

On Thu, Jul 7, 2022 at 12:41 PM Jürgen E. Fischer via Qgis-user <
qgis-user at lists.osgeo.org> wrote:

> Hi Mike,
>
> On Thu, 07. Jul 2022 at 12:20:52 -0400, Mike Treglia wrote:
> > I think I might be missing some of the knowledge I need to implement this
> > for now, which is alright. For example, I'm not sure where I should start
> > adjusting things in that portion of the build_helpers script, and
> > where/when I should run that, or if I'm should modify that portion of
> > build_helpers (ln 107-143) and insert that into
> /c/OSGeo4W/bin/o4w_env.bat,
> > such that the OSGeo4W.bat file will call on the desired environment.
>
> Sorry, I was implying that you're shell savy and pointers were enough.
> Copy fetchenv to your .profile and run it from there (or once you want to
> run
> osgeo4w stuff).
>
>> fetchenv() {
>> }
>
> fetchenv /c/OSGeo4W/bin/o4w_env.bat
>>
> It runs cmd to get a clean copy of the environment and once more with
> o4w_env.bat to get the updated version and then works out the differences,
> makes them shell digestable and sources them to the running shell.
>
> Also works with other software that provides batch files to update the
> environment (like msvc, strawberry perl, venvs in python - just to name
> the few
> the osgeo4w build scripts use it for).
>
>
> Jürgen
>
> --
> Jürgen E. Fischer           norBIT GmbH             Tel. +49-4931-918175-31
> Dipl.-Inf. (FH)             Rheinstraße 13          Fax. +49-4931-918175-50
> Software Engineer           D-26506 Norden
> https://www.norbit.de
> QGIS release manager (PSC)  Germany                 IRC: jef on Libera|OFTC
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220707/e79822ec/attachment.htm>


More information about the Qgis-user mailing list