Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: test for newline in a variable--unexpected results sometimes
- X-seq: zsh-users 23637
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: lilydjwg <lilydjwg@xxxxxxxxx>
- Subject: Re: test for newline in a variable--unexpected results sometimes
- Date: Sun, 16 Sep 2018 20:44:33 +0000
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=odCiDK 91qIB/xgoyE01mn59rD1yhd2ibB7H+lJPSptA=; b=AgZxDcmKr+HyYZOgW12SMb KzIV1w1/OQjcQjIAVWyioVJompEhITYLhAPjEz1VMQiEj4xdlJlErS1B0cf2i10E 1k/yyMF8wDqNhDNudJU6u9EsHJsDZZOY06GQ6kY1noJHr2QeDeMowd+E9DIyJxr0 bA+fDmy02PHcEu/2vMaiv7wIQw3Q0uBpqvzorOCv+goJWE9rdc+QK+dKP4xbXyTv UW8J+JzZzE0Bt37vHXxEBwpFfNpHJW/tRat8LF72GqZORIzKdYPGYxN+MomI9PCn WsJmephA7xw55ECgrEpUyRNI7nQUgy1izjMWAiBES7pXKPsSMMJd4HauFh9qGBrA ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=odCiDK 91qIB/xgoyE01mn59rD1yhd2ibB7H+lJPSptA=; b=OT8BQBNliQb5q7kbChdIcD QDkI+Cva8UkTeGGLUBfD8nrjompncPE73PJQ1vDNwe8fgFj9QA4SwyGxrVUDGphr 2RKKBoIgZ6tH0/VjUMcuGTrB62mZjoSiCqzuEI9EmRBsv5VvkY/YCOrw3UPKsB7E vGI10RXmGqiLLorjKim0h0ORHB/YVJGf6KdjHCJBsWx5G8vjgaJh95NOxrN0oXEn B1YVq2MNMH65kl5NA4JZ96HUDanUv1BaLUilX5JdI2BFRP1m3LppQQhHJTiCk7oE rFrxDOMfSTaFU2GvJiKZHCLH6xAMBpcwvY/iwjC9cOZ9fKDT/xml64OIo4XqVClQ ==
- In-reply-to: <20180916172716.GA27892@lilyforest.localdomain>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20180916172716.GA27892@lilyforest.localdomain>
lilydjwg wrote on Mon, Sep 17, 2018 at 01:27:17 +0800:
> I get output from the skim tool. Then I test if it's multiline or not,
> but it fails mysteriously for some cases.
>
> My test is like this:
>
> [[ $cmd = *\n* ]]
>
In this context, «\n» does not mean a newline; it means either the letter 'n',
or the two-character sequence «\n», but I don't remember which.
> cmd2="cd \ncd /sys/class/leds"
Ditto.. If you try «xxd <<<$cmd2» you'll see the variable's value contains the
two-character sequence «\n».
What you're looking for is [[ $cmd == *$'\n'* ]]. «\n» is an escape sequence
in $''-strings, but not in other kinds of strings.
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author