From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-users-return-23637-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id faf108af for ; Sun, 16 Sep 2018 20:45:06 +0000 (UTC) Received: (qmail 29717 invoked by alias); 16 Sep 2018 20:44:48 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23637 Received: (qmail 7987 invoked by uid 1010); 16 Sep 2018 20:44:48 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-2.6/5.0):. Processed in 6.182732 secs); 16 Sep 2018 20:44:48 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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 == X-ME-Proxy: X-ME-Sender: Date: Sun, 16 Sep 2018 20:44:33 +0000 From: Daniel Shahaf To: lilydjwg Cc: zsh-users@zsh.org Subject: Re: test for newline in a variable--unexpected results sometimes Message-ID: <20180916204433.6k36inmuekgqp3a2@tarpaulin.shahaf.local2> References: <20180916172716.GA27892@lilyforest.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180916172716.GA27892@lilyforest.localdomain> User-Agent: NeoMutt/20170113 (1.7.2) 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