delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/09/05/13:12:18

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A50203851C36
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=cs.umass.edu
Authentication-Results: sourceware.org;
spf=pass smtp.mailfrom=moss AT cs DOT umass DOT edu
Subject: Re: Is this a bug in bash?
To: Greg Borbonus <gregborbonus AT gmail DOT com>
References: <50fad2a4-22c3-8de8-3a0a-394c0b95048b AT gmail DOT com>
<CAOXR0FfRVspg7VCVH3zfvvY6E33JCcyuoU=b6nuvL1bYvFr2qA AT mail DOT gmail DOT com>
<824c5748-594e-cf7c-4bba-4b70f9f593b1 AT cs DOT umass DOT edu>
<CAOXR0Fdvs3M3DgKyK-E+8kz7yAiBZRH769hDHapgXhAgf1zmjA AT mail DOT gmail DOT com>
From: Eliot Moss <moss AT cs DOT umass DOT edu>
Message-ID: <4d932cce-4c25-1458-453b-87d02bb38a03@cs.umass.edu>
Date: Sat, 5 Sep 2020 13:11:26 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
Thunderbird/68.12.0
MIME-Version: 1.0
In-Reply-To: <CAOXR0Fdvs3M3DgKyK-E+8kz7yAiBZRH769hDHapgXhAgf1zmjA@mail.gmail.com>
X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL,
KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: moss AT cs DOT umass DOT edu
Cc: The Cygwin Mailing List <cygwin AT cygwin DOT com>
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 085HBuh3026805

On 9/5/2020 12:57 PM, Greg Borbonus wrote:
> Yeah, thought the expansion might be causing the issue.
> 
> Thanks,
> Greg Borbonus
> 
> On Sat, Sep 5, 2020, 10:44 AM Eliot Moss <moss AT cs DOT umass DOT edu <mailto:moss AT cs DOT umass DOT edu>> wrote:
> 
>     On 9/5/2020 11:29 AM, Greg Borbonus via Cygwin wrote:
>       > Out of curiosity, why are there 2 different sets of quotes?
>       >
>       > Thanks,
>       > Greg Borbonus
>       >
>       > On Fri, Sep 4, 2020, 10:23 PM Bob McGowan via Cygwin <cygwin AT cygwin DOT com
>     <mailto:cygwin AT cygwin DOT com>>
>       > wrote:
>       >
>       >> I am trying to set things up so the Bash profile detects if bash is
>       >> running from the Windows "XWin Server" startup link or not. The startup
>       >> link has the following as the command:
>       >>
>       >> C:\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; exec
>       >> /usr/bin/startxwin"
>       >>
>       >> So I thought I'd try adding the env command to set an environment variable:
>       >>
>       >> C:\cygwin64\bin\run.exe --quote /usr/bin/env startxwin=yes
>       >> /usr/bin/bash.exe -l -c "cd; exec /usr/bin/startxwin"
>       >>
>       >> This works (if there's a better way, I'd be happy to learn of it) but in
>       >> the process of testing I had a problem when echo'ing the variable.
>       >>
>       >> For purposes of describing the bug, I simplified the command as follows:
>       >>
>       >>       env startup=yes bash -l -c 'echo "cmd:  $startup"'
>       >>
>       >> I also added an "echo profile: $startup" to the .bash_profile file.
>       >>
>       >> When I run the above in a Cygwin shell, the output is:
>       >>
>       >> $ env startup=yes bash -l -c "echo cmd: $startup"
>       >> profile: yes
>       >> $
>       >>
>       >> When I run it in a Linux shell, the output is:
>       >>
>       >> $ env startup=yes bash -l -c 'echo "cmd:  $startup"'
>       >> profile: yes
>       >> cmd:  yes
>       >> $
>       >>
>       >> As you can see, the Cygwin side fails to generate any output from the -c
>       >> echo command but on the Linux system there is output.
>       >>
>       >> Normally I'd call this a bug but since this is running under Windows it
>       >> may be some weirdness of the implementation required to create the Linux
>       >> like environment.
>       >>
>       >> The Bash version in Cygwin is  4.4.12(3)-release and for my Debian Linux
>       >> system, it is 5.0.3(1)-release.  So it could also be that it existed in
>       >> Linux 4.x series and has been fixed in the 5.x series.
> 
>     The inner quotes are necessary because there are two spaces beween cmd: and
>     $startup, and the : may be risky unquoted in bash (actually it is ok, but I
>     try to be careful about anything not a letter or digit, etc.).  The outer ones
>     are single quotes, which protect $startup from being expanded before it gets
>     to the new bash.  " " (double) quotes do not prevent $ expansion.  (You want
>     the new bash to do the expansion.)  However, I think this would also work:
> 
>           env startup=yes bash -l -c echo 'cmd:  $startup'

Please put responses at the bottom ("Don't top post") on this list.

I wasn't saying the quotes were a problem, only explaining to a correspondent why they might be 
necessary, etc.

EM
--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019