From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id 6A840386F80C for ; Sun, 10 May 2020 17:52:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6A840386F80C Received: by mail-io1-xd31.google.com with SMTP id y26so7145918ioj.2 for ; Sun, 10 May 2020 10:52:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=VWLt80i+36l4//TemN5qvMToh+QmxiGea0V6kUNQMlc=; b=c/dv7/JoCqJo+UxaPKFHI8UK1KewBcdBc2+sQcJxmif4smDLc+Jt0B4VliFr0EK4IH Vtf1LWEItMr/mvtOG3homs92F05myz4DNzbKbknKwcs8gelDvjLjqaHPayEno3PfsiIM Wyqfasc/oRm6JaCVGQVVaLQn9P6QipJzoDpmcEFujJzU3OAtdZJuGAGWVZn7Yh0qXgaL orlLRuxncfQbiAEBqFTBX+h2AwDtqZnTW8+LPDEIR97qWnWFuy8AtpD+Dph6uCDnElk1 D8oeX3eS8kRztiSyQADp/8zGTdJUdx3hkGeKP/oHHwK+14zU8fCcXjO2zoUWnyAeH4LL CPQw== X-Gm-Message-State: AGi0Pua6RObZwsEzJdFI1gv0lektHC/uiZ3EbRxj0oUF6K0uGyaxd+7X euAwPyq2ChCs61gPdO0W9GpX4rhGmIcwmrAhqqsSyaGbU28= X-Google-Smtp-Source: APiQypI4q5BcbyyM71/cREdP6BZJVMawhL6PH4+eJtc9jU+jBEtpdmpmto/VLvl10M881ewz5MNUjpAaChtXvQZqGsk= X-Received: by 2002:a5e:9904:: with SMTP id t4mr4351250ioj.59.1589133137562; Sun, 10 May 2020 10:52:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Doug Henderson Date: Sun, 10 May 2020 11:52:05 -0600 Message-ID: Subject: Re: Cygwin convert environment paths To: cygwin X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 May 2020 17:52:20 -0000 On Sun, 10 May 2020 at 06:46, Steven Penny via Cygwin <> wrote: > > That Cygwin does convert some environment variables, from Windows format to > Unix format. For example HOME and TMP. But for me at least, are some > important > omissions. > > In general, converting environment variable owned by Windows to cygwin format is a very bad idea. These are the variables that are present in cmd.exe in a vanilla Windows install. The only exception is the PATH variable. Personally, I always set CYGWIN_NOWINPATH=1 in the system environment variables to avoid accidentally calling a windows program while in cygwin. Every time I want to call a windows program from cygwin, I explicitly use its full path. Or I have create and use a shell alias that contains that full path. There is no problem with HOME and TMP (and a few others like TEMP, BROWSER, EDITOR, INFOPATH, PWD, SHELL), because these are not normally set in the Windows environment, or during the execution of cmd.exe. (I can't comment on powershell, as I don't use it.) I experimented with using cygpath to pre-convert several variables that have windows paths, or windows path lists in order to interchangeably run the cygwin version and a windows version of the same application, and to spawn windows programs from cygwin programs and cygwin programs from windows programs. I failed to create an environment that worked for both types of programs at the same time. What I found to partially work for interchangeability was to wrap the cygwin program in a bash script to perform environment conversions, This failed, though, when the cygwin program spawned a windows program which, of course, expected windows paths and path lists in its environment. I also tried wrapping the windows programs with similar conversion, An alternate approach, that worked for my own cygwin code was to create variables like CYG_HOMEDRIVE, or WIN_HOME. But this introduces a different set of problems. I also tried a couple of mingw64 installations: the standard one, and the one packaged with Git for Windows. Programs from those projects tended to work in the windows environment, but allowed you to use linux style file names directly. I did not try mixing cygwin and mingg64 programs. My conclusion was that there is no universal way to make unmodified programs work in the alternate environment. In the OP's specific case of using HOMEDRIVE, he must accept that this is a variable "owned" by windows, and thus not found in the linux environment. Any code that is meant to execute in both cygwin and linux must have code paths for each. And a cygwin program that wants to use a Windows variable, must perform its own conversions, either manually or using cygpath. As I understand it, the cygpath program is a thin wrapper over a library call, so a CFFI (C Foreign Function Interface) might work. HTH Doug -- Doug Henderson, Calgary, Alberta, Canada - from gmail.com