zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: subsitutions and beginning of lines.
Date: Tue, 13 Oct 2015 12:58:19 -0700	[thread overview]
Message-ID: <151013125819.ZM30782@torch.brasslantern.com> (raw)
In-Reply-To: <561C95A9.7020508@eastlink.ca>

On Oct 12, 10:24pm, Ray Andrews wrote:
}
} and I think my question is still a useful exercise: how would we do that
} if there was no easy way?  Combining the words results in a 'command not
} found' error,  since it seems to want to believe that 'history -10 | 
} ....' is one command

Aren't those two unrelated issues?  The "eval" you used is already the
correct way to turn a string formulated as a command line into an actual
command.  The array manipulation you asked about would only apply to
the output of the command after eval.

} so I hafta leave the words unmagically joined yet the normal thing
} seems to be to strip spaces down to a single one when making an array

You may need to go back to a specific example, I fear.  Making an array
how?  By capturing the output of a command?

The normal thing when capturing $(...) in an array context is to treat
all adjacent (consecutive) whitespace (characters listed in $IFS) as a
single word break, yes.  But the spaces aren't being "stripped down to
a single one".  They're being stripped out ENTIRELY, leaving nothing.
It's when putting the array back together into a string again that a
single space is inserted between words.

} It doesn't help that all this splitting is invisible.

This is part and parcel of the whole quoting behavior.  Using double
quotes when you don't want splitting is something you need to habituate.
Once the quotes are in place, you can make splitting explicit/visible.

Peter already gave you the ${(f)"${var}"} and ${${(f)"${var}"}##<->:}
incantations; you can use this directly with $(...) as well:

    ${${(f)"$(eval history $nnumber $sstring)"}##<->:}


  reply	other threads:[~2015-10-13 19:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-11 19:12 Ray Andrews
2015-10-11 20:09 ` Peter Stephenson
2015-10-11 23:05   ` Ray Andrews
2015-10-12  9:34     ` Peter Stephenson
2015-10-12 15:44       ` Ray Andrews
2015-10-12 17:07         ` Ray Andrews
2015-10-13  2:29           ` Bart Schaefer
2015-10-13  2:50             ` Ray Andrews
2015-10-13  5:03               ` Bart Schaefer
2015-10-13  5:24                 ` Ray Andrews
2015-10-13 19:58                   ` Bart Schaefer [this message]
2015-10-13 21:42                     ` Ray Andrews
2015-10-14  0:23                       ` Bart Schaefer
2015-10-14  5:03                         ` Ray Andrews
2015-10-12  2:26 ` Daniel Shahaf
2015-10-12 15:53   ` Ray Andrews
2015-10-12 16:42     ` Peter Stephenson

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=151013125819.ZM30782@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).