zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh-Users List <zsh-users@zsh.org>
Subject: Re: why isn't IFS=$'\n' doing what I expect it to do here?
Date: Sat, 23 Mar 2013 20:47:54 -0700	[thread overview]
Message-ID: <130323204754.ZM26671@torch.brasslantern.com> (raw)
In-Reply-To: <CADjGqHsO-Ysi5KWwLU_SwkGJubcMsM-rFmBvfHw7Fq5ZsuyErg@mail.gmail.com>

On Mar 23, 10:01pm, TJ Luoma wrote:
}
} I don't understand why IFS=$'\n' doesn't seem to be doing what I'd expect

Um, because you're expecting the wrong thing?

(I'm pretty sure this was answered on the list not that long ago, but
danged if I can find the message.)

IFS does not affect the shell's parsing of its own script language.  If
it did, all sorts of scripts would fail any time IFS were exported into
the environment.

(Below here updated slightly because Phil's answer came in while I was
typing.)

As Phil mentioned, what it DOES affect is:

- Splitting or joining of words in shell expansions/substitutions

- The interpretation of input strings e.g. via the "read" builtin
  or "vared"

So as an alternative to Phil's parameter expansion trick, you can do
this:

IFS=$'\n' read -d '' -A APPS <<-\APPS
	Alfred 2

	Bartender

	ddnsa

	Fantastical
	Flycut

	HazelHelper

	MagiCal
	MenuBarFilter
	Mountain

	Should I Sleep
	SizeUp

	Trickster
APPS

(Note this returns 1 because read encounters end of file before it finds
the empty separator.  Since it won't ever find the empty separator, it
may be that this should be made a special case that returns zero.)


      parent reply	other threads:[~2013-03-24  3:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-24  2:01 TJ Luoma
2013-03-24  3:09 ` Phil Pennock
2013-03-24  3:27   ` TJ Luoma
2013-03-24  4:46     ` Phil Pennock
2013-03-24  3:47 ` Bart Schaefer [this message]

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=130323204754.ZM26671@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).