Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Parameter expansion flags question
- X-seq: zsh-users 10255
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: <zsh-users@xxxxxxxxxx>
- Subject: Re: Parameter expansion flags question
- Date: Fri, 12 May 2006 07:45:15 -0700
- In-reply-to: <DD74FBB8EE28D441903D56487861CD9D097172A4@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <DD74FBB8EE28D441903D56487861CD9D097172A4@xxxxxxxxxxxxxxxxxxxxxx>
On May 12, 12:02pm, John Cooper wrote:
} Subject: RE: Parameter expansion flags question
}
} > 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?
It's the same as the difference between
string=""
array=( word "$string" word )
print $#array
and
string=""
array=( word $string word )
print $#array
An unquoted empty string is discarded; a quoted empty string is retained.
Effectively the :# construct discards the quoted empty string, leaving an
unquoted one in its place, which the shell in turn discards when building
the final array.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author