public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Andrey Repin <anrdaemon@yandex.ru>
To: Thomas Wolff <towo@towo.net>, cygwin@cygwin.com
Subject: Re: [ANNOUNCEMENT] Updated: mintty 2.9.5
Date: Fri, 07 Dec 2018 21:50:00 -0000	[thread overview]
Message-ID: <199122924.20181208004157@yandex.ru> (raw)
In-Reply-To: <2f3cf57e-0b44-8c4a-b075-24743e4443d2@towo.net>

[-- Attachment #1: Type: text/plain, Size: 2722 bytes --]

Greetings, Thomas Wolff!

> Am 06.12.2018 um 22:32 schrieb Andrey Repin:
>> Greetings, Achim Gratz!
>>
>>> a) Just warn about the missing PATH component without changing the PATH.
>>> b) Give the user an option to let the command run with a separate PATH.
>>> Indeed there might be other things that are missing in the environment,
>>> so instead of just fixing up PATH you might consider using a wrapper
>>> that the user can change.
>> This is an interesting point.
>> Probably letting the user specify custom $PATH for quick commands (and save
>> current %PATH% as $ORIGINAL_PATH) may be the best choice.
>> The default can be %Cygwin%\bin:%PATH% or %PATH%:%Cygwin%\bin, I'm not very
>> concerned as long as it's explicit and customizable.
> I didn't expect the setup of this specific feature to be so strongly 
> advocated :)
> In any case, things shouldn't become too complex. What I can image is an 
> option UserCommandsPATH
> with one optional placeholder %s which would be replaced with the 
> environment PATH;
> default /bin:%s, corresponding to current behaviour.

Using native paths and environment variable syntax, you can always use
ExpandEnvironmentString to get the %PATH% you need.
Cygwin DLL will then convert it to own version, avoiding you mangling it
yourself.
And I would strongly discourage from using placeholders familiar for you, but
unexpected by the end user and taken from entirely different area of knowledge.

BTW, Cygwin itself does it differently. %Cygwin%\bin is converted to /usr/bin.

>> If anybody need a wrapper, they may write and use it by themselves.
>>
>> (I already have one, written in TCC, working quite well.)
> Out of curiosity, what's TCC and what does your wrapper do?

This is an augmented CMD-like scripting platform.
https://jpsoft.com/products/tcc-cmd-prompt.html

Its "runtime" variant, TCC-RT, contains only scripting core, no interactive
functionality, and is distributed for free.

I attached the pair of scripts that I use to wrap .sh/.awk/.pl/etc. with.
In manual mode, I can use it to launch any script provided /usr/bin/env can
deal with it, as it's basically a wrapper around /usr/bin/env, which ensures
that the first argument (the script name) has Cygwin notation.
The fix-path thing is necessary to tweak startup behavior. Normal operation
environment don't have /usr/local/bin in %PATH%, as that hides some
Cygwin-specific scripts which have native counterparts in a different place.

P.S.
The %[variable] notation I use is not strictly necessary.
%var or %var% works equally well, but may be disabled in options.
I'm just playing on the safe side.


-- 
With best regards,
Andrey Repin
Saturday, December 8, 2018 0:16:49

Sorry for my terrible english...

[-- Attachment #2: cygwrap.btm --]
[-- Type: application/octet-stream, Size: 730 bytes --]

@SET PROMPT=@$S$P$_
@ECHO OFF
ON BREAK REM

IF "%~1" == "--install" GOTO :SETUP
IF "%~1" == "" GOTO :BANNER

CALL "%~dp0fix-path.btm"

SET ENV=%@PATH[%@FULL["%~0"]]env.exe
SET CMDNAME=%@EXECSTR[cygpath.exe -u "%~1"]
SHIFT

SET LANG=%@EXECSTR[locale -uU]
"%[ENV]" -- "%[CMDNAME]" %$
QUIT %?

:BANNER
ECHO Cygwin script wrapper.
ECHO Usage:
ECHO.
ECHO   %@FILENAME["%~0"] script [parameters]
ECHO   %@FILENAME["%~0"] --install [.ext ...]
ECHO.
ECHO The ".sh" extension is always registered on install.
QUIT

:SETUP

FTYPE unixshell.script="%[ComSpec]" /S /C "%@FULL["%~0"]" "%%1" %%*
SHIFT
DO EXT IN /L .sh %$
  IFF "%@LEFT[1,%[EXT]]" == "." THEN
    ASSOC %[EXT]=unixshell.script
  ENDIFF
ENDDO

[-- Attachment #3: fix-path.btm --]
[-- Type: application/octet-stream, Size: 284 bytes --]

@ECHO OFF

SET OLDPATH=%[PATH]
SET _CBIN=%@RTRIM[\,%@PATH[%@FULL["%~0"]]]
SET PATH=%@RTRIM[\,%@PATH[%[_CBIN]]]/usr/local/bin;%[_CBIN]
DO _path IN /T";" /L %[OLDPATH]
  IFF "%[_path]" != "%[_CBIN]" THEN
    SET PATH=%[PATH];%[_path]
  ENDIFF
ENDDO
UNSET OLDPATH _CBIN _path

[-- Attachment #4: Type: text/plain, Size: 219 bytes --]


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2018-12-07 21:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05 10:28 Thomas Wolff
2018-12-05 20:21 ` Achim Gratz
2018-12-05 21:46   ` Thomas Wolff
2018-12-06  0:20     ` Andrey Repin
2018-12-06  7:22       ` Thomas Wolff
2018-12-06 16:25         ` cyg Simple
2018-12-06 19:39     ` Achim Gratz
2018-12-06 21:35       ` Andrey Repin
2018-12-07 20:12         ` Thomas Wolff
2018-12-07 21:50           ` Andrey Repin [this message]
2018-12-09 23:22             ` Thomas Wolff
2018-12-10  2:05               ` Andrey Repin
2018-12-10  4:58                 ` Thomas Wolff
2018-12-10 13:20                   ` Andrey Repin
2018-12-10 13:54                     ` Thomas Wolff
2018-12-07 13:45       ` Brian Inglis
2018-12-10 18:21 ` Achim Gratz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199122924.20181208004157@yandex.ru \
    --to=anrdaemon@yandex.ru \
    --cc=cygwin@cygwin.com \
    --cc=towo@towo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).