zsh-users
 help / color / mirror / code / Atom feed
From: "John Cooper" <john.cooper@eu.citrix.com>
To: "Bart Schaefer" <schaefer@brasslantern.com>, <zsh-users@sunsite.dk>
Subject: RE: Parameter expansion flags question
Date: Fri, 12 May 2006 12:02:30 +0100	[thread overview]
Message-ID: <DD74FBB8EE28D441903D56487861CD9D097172A4@lonpexch01.citrite.net> (raw)

  > Placement of the quotes is important:
  >    for site in ${(f)"$($SITEMGR -i)":#}

OK, changing the placement of the quotes to the above fixes it. There's
just one thing I'm a little puzzled about - in the case where $SITEMGR
produces no output, won't "$($SITEMGR -i)" be the empty string? If so,
why is :# needed? It seems it will just replace an empty string with
another empty string?

Thanks,

    --- John

-----Original Message-----
From: Bart Schaefer [mailto:schaefer@brasslantern.com] 
Sent: 11 May 2006 17:39
To: zsh-users@sunsite.dk
Subject: Re: Parameter expansion flags question

[skipping around a bit]

On May 11, 10:59am, John Cooper wrote:
}
} One final thing - when I entered the "read" example into the shell as
} stated I got syntax errors. These were resolved by using "do" and
"done"
} instead of braces - is this to be expected?

Yeah, I messed up.  I never use the form with the braces, but you did
in your original "for" sample, so I tried to keep it with "while".  I
forgot that for "while" loops it only works when the first condition
is [[ ... ]] or (( ... )).

} Thanks for the detailed reply - it seems using "read" is the most
} straightforward approach. However, in the interests of learning more
} about expansions, I've been trying your suggestions and they don't
seem
} to work as expected.

Oh, duh.  I spaced that there were multiple lines of output from the
$SITEMGR program.  Obviously you need to process each line separately
before applying the subscript.

(This cold I'm coming down with must be affecting me worse than I
thought.)

} If I add the ":#pattern" operator to the original function, the "for"
} loop is still executed once in the case where $SITEMGR produces no
} output:

} delsites4 () {
}         for site in "${(f)$($SITEMGR -i):#}"

Placement of the quotes is important:

    for site in ${(f)"$($SITEMGR -i)":#}

If it still happens, I think it's because of Cygwin line termination.
Instead of an empty string when splitting with (f), you're getting a
string having a single carriage-return character.


             reply	other threads:[~2006-05-12 11:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-12 11:02 John Cooper [this message]
2006-05-12 14:45 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2006-05-15  9:01 John Cooper
2006-05-11  9:59 John Cooper
2006-05-11 16:38 ` Bart Schaefer
2006-05-10  9:22 John Cooper
2006-05-10 17:28 ` Bart Schaefer

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=DD74FBB8EE28D441903D56487861CD9D097172A4@lonpexch01.citrite.net \
    --to=john.cooper@eu.citrix.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /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).