Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
test for newline in a variable--unexpected results sometimes
- X-seq: zsh-users 23636
- From: lilydjwg <lilydjwg@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: test for newline in a variable--unexpected results sometimes
- Date: Mon, 17 Sep 2018 01:27:17 +0800
- Disposition-notification-to: lilydjwg@xxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :disposition-notification-to:user-agent; bh=/fk0T1sdRwUfJiN2cAIkz1b5H5LcjXYRjTR4j9vQ2Vg=; b=J1SitgSGWv5DLyhFYNySKZcn0k1YO8xHmkf7CYtU1se6cQ8J0sCr15FYzUxKiQn+d0 9HW3lgef6QabBV1n3X6ycEzFEr+whsrMrQ4Uav9DlzT7fT2Iawhl4Aos2pow17MDhURD 2+OjcG6lLJ4U0V/c2jpAawAiJnAZ/nRNEl5D+o8Z3W/fnISCO8g5qh3Sg8VRiONZyp6l 4ksOrR3sWdLw/qCvUVd5swKYJakQK/8oZ7tun3hsRng7wNAYurjjIVUfvRCK1YcmEPwG 73NSjS/ZBK/oTAS9xud1goORk/sIbAwWgZ/Yg2q+BHgm1KlISvzY50bJUvJtubDJQ8uS VJZA==
- 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
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* ]]
It doesn't work for the following data (I've echoed $cmd to the file):
> cat -E log
cd $
cd /sys/class/leds$
This fails too:
[[ $(<log) = *\n* ]]
But manually set the variable to the same text it works:
cmd2="cd \ncd /sys/class/leds"
[[ $cmd2 = *\n* ]] # this succeeded
Here's the hex dump of the file:
> xxd log
00000000: 6364 200a 6364 202f 7379 732f 636c 6173 cd .cd /sys/clas
00000010: 732f 6c65 6473 0a s/leds.
What's going on? I'm confused....
--
Best regards,
lilydjwg
Messages sorted by:
Reverse Date,
Date,
Thread,
Author