Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

test for newline in a variable--unexpected results sometimes



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