From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by sourceware.org (Postfix) with ESMTPS id 31CAD3851C36 for ; Sat, 5 Sep 2020 16:57:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 31CAD3851C36 Received: by mail-ej1-x641.google.com with SMTP id p9so12542915ejf.6 for ; Sat, 05 Sep 2020 09:57: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:cc; bh=gDIfV69PlKBgg0WmJiprRs97ZqdGDEW/FmAl7PsHC4o=; b=rtCNu0bqhw5ifON0fqs7hV2s2NIFpWOPJDf26EVQ8G0mjb92MLW0vTXw2BpeMZJ4oy ec3JfhxQqh1x5TCTC8DLMjXJOADkHcykSYNrPJVNsuB1xRLFOEpTBSHR9/xsGRprwGPJ 1FjQyMwKuQL5wRNPwCPFqQ/4Gc++8Ibl5uoODmM5Ns9/Gj8LSKm66M0musLCOrr+cNPK mllMwIIkMC79O4nvxXt4M5mRYE0+PJ8M4spJI1DTJDklvNbJoKCPxX6sTCitOYU4aB07 Q7D7BaTI5/vHOGKgoPAX76MOOGxnau2nXC/0n6lTrJeZHI+4xeTplBV5phf3xAyT5FFO ChOQ== X-Gm-Message-State: AOAM533IIImoBNLHK6q5EFkBJ5D6uahVZ19d1BGL5rTgkhe/3YzLnin4 kuW79DzoNJ3pyZ+fOnSTDHlputK34T2fb39+PtI= X-Google-Smtp-Source: ABdhPJx6c8Qce+QiWtuI7BZbhiZy7+8BJ0aGlalB1u5txsr++V48C/xfNIP2BNblqJlpvaR0YXD63OI8c8A13zc4dcs= X-Received: by 2002:a17:907:aa9:: with SMTP id bz9mr12727911ejc.421.1599325037353; Sat, 05 Sep 2020 09:57:17 -0700 (PDT) MIME-Version: 1.0 References: <50fad2a4-22c3-8de8-3a0a-394c0b95048b@gmail.com> <824c5748-594e-cf7c-4bba-4b70f9f593b1@cs.umass.edu> In-Reply-To: <824c5748-594e-cf7c-4bba-4b70f9f593b1@cs.umass.edu> From: Greg Borbonus Date: Sat, 5 Sep 2020 11:57:05 -0500 Message-ID: Subject: Re: Is this a bug in bash? To: moss@cs.umass.edu Cc: Bob McGowan , The Cygwin Mailing List X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, 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 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: Sat, 05 Sep 2020 16:57:19 -0000 Yeah, thought the expansion might be causing the issue. Thanks, Greg Borbonus On Sat, Sep 5, 2020, 10:44 AM Eliot Moss 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 > > > 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' > > Regards - Eliot Moss >