X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BD373858022
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1609291901;
	bh=eWfkORNMaUZg3ZUUgtURrNYgFymLIyH/KgYaT+Yn6fs=;
	h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=XZQ6t8L8nTGlbIOQcetKUrwjQIWqo1wlJghSViDkeCUj3wqlrovyJ+wTlDJsovalH
	 Q2PsQ2HTVH/tUQOId6DqLXGVaDHHxj84qNfcLFcgvBUV991bqu/xBpXd/LMCbEfgco
	 Y8Q3gW5a+nsczQS8UTS/ZIWZcr7yJs2WgwgHXnLM=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2E2973858022
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=RVVnx4xcr2YBc28Q6jYl6crkBfmkmxX3m9ImYDxqkaI=;
 b=QogIaidk18SdsGswf64V+UMaH2pob35IJlbTnbM7KxEQUPpGHscoC/6kh41VvkLylO
 I5HTZuqMRGxQGIVSH44qmmY74xxnd9rj0klEK70RDXeof+HMm75XtWoEXbS/0d/DFlo+
 3dZqOyXrwtI39kU0PHfc1U/ufd7etbUW0/h8GkCSpLuOarfYnVbrMY9oApqnjHHfab+g
 4I1hdiTN8BmxvUqZ48B3cfXfzDYrB5MvJGi3z9UBViU0qzcX7Vqo6CNfv4Vg4lFV0KMr
 Pp63T9NdkqCK+Qqsm36IHqMX7VrBttWKOFQsGcWqp9b3ASYa5UBl0XG4hjKkPfOfobc0
 Rc/Q==
X-Gm-Message-State: AOAM5311djU6UnPjpj8JOkH2q1S/CjJCVys5KSGxIcXZxO1cw5rDn6Bl
 nuwadMJ7havTuM+1Zl5j9G/cKF9GubuI+JH3t7fiIo2xGiAP0w==
X-Google-Smtp-Source: ABdhPJw0XTChgVQkziwFnvCB0Ka1cMrDoG4n5QAhUnixf2MqBKMzH6Qp2Qc85WBTpCEZpa5G4vJPHidcuPOhN6J20ZU=
X-Received: by 2002:a37:a917:: with SMTP id s23mr50826566qke.214.1609291896512; 
 Tue, 29 Dec 2020 17:31:36 -0800 (PST)
MIME-Version: 1.0
References: <1939012153.20201227050421@inbox.ru>
 <1626660026.20201230005056@inbox.ru>
In-Reply-To: <1626660026.20201230005056@inbox.ru>
Date: Tue, 29 Dec 2020 18:31:25 -0700
Message-ID: <CAJ1FpuPec6H761z8-+NK+wqE+ZaJr8f8umyfjCMVVmikGCFquw@mail.gmail.com>
Subject: Re: tee: 'standard output': Permission denied
To: cygwin <cygwin@cygwin.com>
X-Spam-Status: No, score=-0.3 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,
 WEIRD_QUOTING autolearn=no autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
 server2.sourceware.org
X-Content-Filtered-By: Mailman/MimeDel 2.1.29
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Doug Henderson via Cygwin <cygwin@cygwin.com>
Reply-To: Doug Henderson <djndnbvg@gmail.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: "Cygwin" <cygwin-bounces@cygwin.com>

On Tue, 29 Dec 2020 at 14:48, Andry via Cygwin <cygwin@cygwin.com> wrote:

>
>   "%CYGWIN_ROOT%\bin\bash.exe" -c "{ cd ""%PWD:\=/%""; CHERE_INVOKING=.
> ""%CYGWIN_ROOT:\=/%/bin/bash.exe"" -l -i; } 2>&1 |
> ""%CYGWIN_ROOT:\=/%/bin/tee.exe"" -a ""%PROJECT_LOG_FILE:\=/%"""
>   ```
>

In most situations like this, I  create a bash script containing everything
I want to do within bash. Trying to get all the quoting right is a pain in
the brain.

The key lines in my .bat files (with CRLF endings) are:

set D=folder  *the directory containing script
set SCRIPT=script.sh   *the name if the bash script file (with LF endings)
set BASH=C:\cygwin64\bin\bash.exe
%BASH% --noprofile -o errexit -o nounset -c %D%/%SCRIPT%

Note the forward slash between script directory and script file, very
important!
Also note there is no quoting required - a big win.

First command in the bash script is usually an "export PATH=..." command.

Of course, if there is an actual permissions error, this will not fix it,
but it will allow you to more easily diagnose the problem.

HTH
Doug

-- 
Doug Henderson, Calgary, Alberta, Canada - from gmail.com
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
