rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: "Smarasderagd" <smarry@vex.net>
To: fosterd@hartwick.edu, rc@hawkwind.utcs.toronto.edu
Subject: Re: flattening a command substitution
Date: Tue, 11 Jul 2000 12:39:49 -0500	[thread overview]
Message-ID: <20000711163949.21962.qmail@pantransit.reptiles.org> (raw)

"Decklin Foster" <fosterd@hartwick.edu> writes:
>Is there a way to perform a command substitution and flatten it all at
>once? For example, say I want to work with a pwd that has spaces:

Or worse, tabs.

>Now, there are two ways I can get it to work: use a newline as the
>ifs-value, or have a temporary variable:
>
>pwd=`{pwd}
>ls $^pwd

I usually do:

nl = '
'

somewhere at the top of the script.  I sometimes also have tab = '	'.
Later, if I want to ignore other whitespace:

ls ``($nl){pwd}

>Neither strike me as being very elegant. The first option doesn't
>generalize to commands with multi-line output, and having to waste a
>variable seems wrong. Does anyone have a better idea?

For commands with multi-line output, ``(){command} seems like the right
thing to me.  As others may have discovered, it still splits the output
if it happens to contain nulls, which I actually find rather useful if
I want to do things with the output of find with the -print0 option...


             reply	other threads:[~2000-07-12 22:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-11 17:39 Smarasderagd [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-07-08  2:50 Decklin Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000711163949.21962.qmail@pantransit.reptiles.org \
    --to=smarry@vex.net \
    --cc=fosterd@hartwick.edu \
    --cc=rc@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).