Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15507

Re: Command grouping

Path csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Mischa Baars <mjbaars1977.bug-bash@cyberfiber.eu>
Newsgroups gnu.bash.bug
Subject Re: Command grouping
Date Mon, 14 Oct 2019 12:37:34 +0200
Lines 74
Approved bug-bash@gnu.org
Message-ID <mailman.640.1571049616.9715.bug-bash@gnu.org> (permalink)
References <acdb21fe37e928c2063c95ec1d013fe695e3bdf1.camel@cyberfiber.eu> <06070f12-033d-0736-1733-a035629104cd@case.edu> <735ae0ed6542416188552545d16a02936070e493.camel@cyberfiber.eu> <20191013105449.45845e406ffc7cb4e1829ea2@plushkava.net> <17b2e46e399a26eabfb72206fccebcb49ace9dad.camel@cyberfiber.eu>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1571049617 2350 209.51.188.17 (14 Oct 2019 10:40:17 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cyberfiber.eu; s=default; h=Content-Transfer-Encoding:MIME-Version: Content-Type:References:In-Reply-To:Date:To:From:Subject:Message-ID:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=x2pLUdC7iS6FVWI14UXarEtUXzy9knhMGyGfwhkxilM=; b=eEmwNFGkJeh5Uwpv3BghhuE8iM 8wDvUqB2nb/e37CHq5r+ID+wfHJxxhtyXIkvJKD0gmUxQivFrqErQ1GjpX1hPw2jMEeM2sHe6XBvT VZXCxOP1KEq8m7CKPfcD9W8IB++Q6n8UFIK+fVjCjy3FOYVFwiJeg/BFl/UG6v2mnokwnWRjbepYD HrShHUht3uEV0wUi2AqkZ3iPr7b6Ipz60LNY90RBDr5a6NpaygWQL7XdNTiSiJFFBCvK4qyxmuMtj V8Xowt+BaSyme42QYB2RS9A41+NXz+NA2Rra6GwiEVKi5FVhupc+W83zsChU6+0S6+7QsqpY8SOdm elbzkgZg==;
In-Reply-To <20191013105449.45845e406ffc7cb4e1829ea2@plushkava.net>
User-Agent Evolution 3.32.4 (3.32.4-1.fc30)
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - www98.totaalholding.nl
X-AntiAbuse Original Domain - gnu.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - cyberfiber.eu
X-Get-Message-Sender-Via www98.totaalholding.nl: authenticated_id: mjbaars1977.bug-bash@cyberfiber.eu
X-Authenticated-Sender www98.totaalholding.nl: mjbaars1977.bug-bash@cyberfiber.eu
X-Source
X-Source-Args
X-Source-Dir
X-Originating-IP 185.94.230.81
X-SpamExperts-Domain out.totaalholding.nl
X-SpamExperts-Username 185.94.230.81
Authentication-Results totaalholding.nl; auth=pass smtp.auth=185.94.230.81@out.totaalholding.nl
X-SpamExperts-Outgoing-Class unsure
X-SpamExperts-Outgoing-Evidence Combined (0.61)
X-Recommended-Action accept
X-Filter-ID Mvzo4OR0dZXEDF/gcnlw0eFAaCtHsYYurt+XvhXi9QGpSDasLI4SayDByyq9LIhVvFD4upwGOM6x DZdMlDima0TNWdUk1Ol2OGx3IfrIJKywOmJyM1qr8uRnWBrbSAGDu+MuAbNHX7Qd+PEd0ms9H80D SEpCfISRYCKsig5kq2Lk/Q+Z/YUfODhJOvwSZGABZIOQYaDXB30lsHjt7j8HkKlf0W50n6AuXIMv hlU4BzhNwITHhljpqKk+Ratvp0JPhh8OzJWiBXhoyvdBz/MpXE9H2jTXggI6z2khZfw60smPWmpe Lxu1AJ+qib20747kaNJScrTO/pZaeJIu6m+Lf8LdW9R2NIKzCKQr+WJx9f4kOuOzFkeHLUDMw9Qs pmHgCCp1v8mNt1Vl9tz1z4nGm37niLJQJzxpqSdmGj2doliDRuiUzsH+sEW6XTJyNgcbQ18PG1yr OcflUFS53w7gtXQmZupE66h/n5scs0KBvjbXs2KsRjKrCowEavDwQuKo7zq0HII/r2LRCHmd0fmF 5EInus9dluOkp4ju/FG+94Igr/U0flMcy2Vi/IcBgY4aCN1vmHLh3z+T5GW+QPsBOahnaR+eDmt1 fCO+lThL5cCFVHWJ3UYsockG/KOUjXDUT8nmmGy/7G8HpDvTzgN6n7/q3DNNKz25M2Z+Dt8ackDU bljiaRF/vlRXT3o1imSpBfcw9o8J66Y6FulVnTe0hT3kBla3NA44NlhoFL9Bo9qL9u2uaWELzk6S YlFn6bLZgtOIWWXJf3vgKkCbA5ZC38Cmeql2i33lnWzZsHB92b/xfqhFxg7rcHClLkLz3wIdij1Z Tv3jxCnI9qlGdNyBWE4vidrAbzPztKfs4s5XguKRrMBCw1/u+5rrKwDEUCKWdvdIJhVgNJ0fggoG fmhNOX0cq+P4uL4HSyVl3hpp2LZvrrsT/VNex5v3YWiVw9Os8vmwpPPe2n3Cm8ZizfwlX5KB/QOI s9FdNJaYUQ8rI/SDFvpVD0PJ/WZ3Kb99YO+dv6HUiAJBto9jfRV+OpvF1OLUBiSvJiF5IB/9zuRH wdabcRAg3alRQNw5f8BkEdx/
X-Report-Abuse-To spam@filter01.totaalholding.nl
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2a02:40c0:1:2:ffff::8
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <17b2e46e399a26eabfb72206fccebcb49ace9dad.camel@cyberfiber.eu>
X-Mailman-Original-References <acdb21fe37e928c2063c95ec1d013fe695e3bdf1.camel@cyberfiber.eu> <06070f12-033d-0736-1733-a035629104cd@case.edu> <735ae0ed6542416188552545d16a02936070e493.camel@cyberfiber.eu> <20191013105449.45845e406ffc7cb4e1829ea2@plushkava.net>
Xref csiph.com gnu.bash.bug:15507

Show key headers only | View raw


On Sun, 2019-10-13 at 10:54 +0100, kfm@plushkava.net wrote:
> On Sun, 13 Oct 2019 10:09:26 +0200
> Mischa Baars <mjbaars1977.bug-bash@cyberfiber.eu> wrote:
> 
> > On Sat, 2019-10-12 at 10:42 -0400, Chet Ramey wrote:
> > > On 10/12/19 9:02 AM, Mischa Baars wrote:
> > > > Hi,
> > > > 
> > > > Perhaps to better have a look at this mail, than the previous mail.
> > > > 
> > > > In trying to group commands, in this case compiler commands, I found some peculiarities while trying different combinations of the 'Internal Field
> > > > Separator'
> > > > and the 'Parameter Expansion' operator ${parameter@P}.
> > > 
> > > I haven't looked at this in any depth, but you should realize that running
> > > 
> > > declare IFS=$(printf ' \t\n')
> > > 
> > > will result in IFS being set to space and tab, since command substitution
> > > removes the trailing newline. Maybe that will make a difference.
> > > 
> > 
> > Hi Chet,
> > 
> > The bash manual page tells us that is the default value, nothing special.
> > 
> > I was trying to remove the whitespace, such that whitespaces are allowed in project directory names, as was considered the default scenario as far as I
> > know.
> 
> You are not removing the whitespace values from IFS. Instead, you are re-asserting the default value of IFS, only with \n missing (for the reason that Chet
> describes). Given that the output of your find command is newline-delimited, doing so will not end well. Writing IFS=$'\n' may function as you expected.
> However, this is an intrinsically broken approach to begin with. See https://mywiki.wooledge.org/DontReadLinesWithFor.
> 
> Instead, consider any of the following options:-
> 
>   * find -exec or -execdir
>   * a for loop that iterates over a glob
>   * a while/read loop that consumes find's output (using -print0, ideally)
> 
> Your problems are compounded by failing to quote the expansion of i in the course of invoking gcc (lines 4-5), and by the flawed attempt at a workaround
> (lines 2 and 6-7). See https://mywiki.wooledge.org/BashFAQ/050. Not only that, but the *.c argument conveyed to find should be quoted, so as to inhibit
> pathname expansion.
> 
> Here is an example of how one might use for:-
> 
> shopt -s globstar
> for i in ./pace/**/*.c; do
>   gcc -o "${i%.c}" "$i"
> done
> 

Hi Kerin,

I believe you're missing the point. You were probably distracted by me brabbling about whitespaces.

Again. When scripting, commands often do not fit on one line. To overcome this problem, let's try to separate the commands from the loops:

--- emphasis on separation ---

shopt -s globstar; export E0="\${i}"; for i in ./pace/**/*.c; do ls ${E0@P}; done;		# functions as supposed to
shopt -s globstar; export E0="ls \${i}"; for i in ./pace/**/*.c; do ${E0@P}; done;		# functions as supposed to

--- emphasis on pathname expansion ---

shopt -s globstar; export E0="\${i}"; for i in ./pace/**/*.c; do ls "${E0@P}"; done;		# functions as supposed to
shopt -s globstar; export E0="ls \${i}"; for i in ./pace/**/*.c; do "${E0@P}"; done;		# does not function as supposed to

Aliases are not defined in makefiles, and I remember there to be something uncomfortable with functions in the loop too, I would have to look that up. So we'll
have to do with variables being used to define functions.

Regards,
Mischa.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Command grouping Mischa Baars <mjbaars1977.bug-bash@cyberfiber.eu> - 2019-10-14 12:37 +0200

csiph-web