Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: string overwrites string when echoed
- X-seq: zsh-users 22888
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: string overwrites string when echoed
- Date: Sun, 10 Sep 2017 19:57:58 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1505069879; bh=n+HX7plXg7CzVLF3UptiaQXm5YY5lOk7gEaP+Uv68Js=; h=Date:From:To:Subject:In-Reply-To:References; b=XSibnx/NoZjRRb4hbNOCD2yGhmCpPEIctqPhY4NGk+gY3AbI+0OQx7hGYJ6VcaYZ0 d5koRPpKS1M1hXV5McAdnKghmJdbhFYEaurb+jTyk99VbTwpa/NkRTQgokXWAjIo7J JZyqjyCVXnEyY5sfKVYux+SCY3k8X3KSK94IBNmhU2prfJHIE4QihsP+8xbg4c0bcK z+BrZvUR84aQcoVixC5lTO4WiA39KonaxWF68LVc2T3z/GJixrRzc32hg3W0ySEj/c Mn4DKP0295TTs7BP9qURt97z0Omqe2dBzGDUVR/ZeHs41aJJvVsbkVIXYH2YGBz/U/ 1X9ma81wcgcew==
- In-reply-to: <86o9qimn03.fsf@zoho.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <86o9qkqbes.fsf@zoho.com> <170909100149.ZM8451@torch.brasslantern.com> <86shfumrzm.fsf@zoho.com> <20170910175943.77a8313a@ntlworld.com> <86o9qimn03.fsf@zoho.com>
On Sun, 10 Sep 2017 20:23:08 +0200
Emanuel Berg <moasen@xxxxxxxx> wrote:
> Feel free to elaborate on ${reply%%$'\r'}.
> What does it do? Remove the last char of the
> string if it matches the char given?
%% is a standard pattern match operator (works in most shells) that
removes the longest possible match of the following pattern. % is
similar but removes the shortest possible match: I used %% because they
do the same thing in this case (it's a single fixed character) and I
happen to know the longest match is generally more efficient to
evaluate. This is documented in the PARAMETER EXPANSION section of the
zshexpn manual.
$'...' is an increasingly common form of quoting that allows escape
sequences like the print builtin, so $'\r' exands to a carriage return.
This is documented in the section QUOTING in the zshmisc manual page
(except it doesn't say much more than what I did before you have to go
away and read the entry for the print builtin).
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author