Web lists-archives.com

Re: portable use of dos2unix WAS: Re: textmode for stdout, what is "correct" now?

Hi Andrey,

On 2/15/19 7:35 PM, Andrey Repin wrote:
> Greetings, Michael Haubenwallner!
>> On 2/15/19 1:45 PM, Andrey Repin wrote:
>>> Greetings, Michael Haubenwallner!
>>>>> For scripting, d2u should help.
>>>> Plus, to be portable: type d2u >/dev/null 2>&1 || d2u() { cat; }
>>> _d2u="$( which d2u 2> /dev/null || echo cat )"
>> To be honest, this is less portable for some reasons:
>> * "$(...)" is not Bourne Shell (/bin/sh) but POSIX Shell (ksh, bash, ...)
> And /bin/sh is a POSIX shell. I don't know what you are trying to say here.
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03

Well, /bin/sh *shall* be a POSIX shell. But the reality is not there yet:

>> * "which" is C Shell and has it's own troubles (may load ~/.cshrc first)
> $ which which
> /bin/which
> It's a separate executable, unless shell provides an override.
> How it could possible load foreign RC file is beyond me.

On AIX for example, /usr/bin/which is a csh script by itself:

$ type which
which is /usr/bin/which

$ file /usr/bin/which
/usr/bin/which: shell script  - csh (C shell)

$ head -n5 /usr/bin/which
#!/usr/bin/csh -f
set prompt = "% "
if ( -f ~/.cshrc) then
        source ~/.cshrc

Now imagine what happens when ~/.cshrc does mess with PATH.

Anyway: To find something along PATH, I do prefer some shell builtin rather
than something to be found along PATH.

> ----
> I have a different question though. The commands you presented in the OP
> look like you aren't using Cygwin-suppied OpenSSL binary.

This is true: The Cygwin distro does provide openssl-1.0.2p, but I'm building
the *portable* Gentoo Prefix distro on Cygwin, with openssl-1.1.1a already.
But whenever the Cygwin distro would bump to openssl-1.1, the same problem
would arise there as well, just becomes noticed much later probably.


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