zsh-users
 help / color / mirror / code / Atom feed
* test for newline in a variable--unexpected results sometimes
@ 2018-09-16 17:27 lilydjwg
  2018-09-16 20:44 ` Daniel Shahaf
  0 siblings, 1 reply; 7+ messages in thread
From: lilydjwg @ 2018-09-16 17:27 UTC (permalink / raw)
  To: zsh-users

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-09-17  3:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-16 17:27 test for newline in a variable--unexpected results sometimes lilydjwg
2018-09-16 20:44 ` Daniel Shahaf
2018-09-16 20:53   ` dana
2018-09-16 21:44     ` Dangling reference in zshroadmap(1) (was: Re: test for newline in a variable--unexpected results sometimes) Daniel Shahaf
2018-09-16 22:16       ` dana
2018-09-16 22:56         ` Daniel Shahaf
2018-09-17  3:20   ` test for newline in a variable--unexpected results sometimes lilydjwg

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).