[SLUG] Newlines in environment variables

2005-05-29 Thread Peter Hardy
Pretty basic shell question, but it's Monday morning and my brain hasn't
warmed up yet.

I have the following bit of shell script to accept messages piped from
evolution filters and pop up a notice on screen:


message=Message received

`egrep (^From:|^Subject:)`



xmessage -nearmouse $message

(I'd much rather use zenity or some other xmessage replacement, but
nothing else is available in this environment)

Now, running this script with bash compresses $message to a single line,
while zsh keeps the newlines intact. So I'm wondering how to achieve the
same thing with bash.

Cheers,
-- 
Pete

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Newlines in environment variables

2005-05-29 Thread tatz
Hi, good morning!?

From: Peter Hardy [EMAIL PROTECTED]
Date: Mon, 30 May 2005 11:30:48 +1000

 I have the following bit of shell script to accept messages piped from
 evolution filters and pop up a notice on screen:
 
 
 message=Message received
 
 `egrep (^From:|^Subject:)`
 
 
 
 xmessage -nearmouse $message
 
 (I'd much rather use zenity or some other xmessage replacement, but
 nothing else is available in this environment)
 
 Now, running this script with bash compresses $message to a single line,
 while zsh keeps the newlines intact. So I'm wondering how to achieve the
 same thing with bash.

xmessage -nearmouse $message

If you don't quote the variable, it is separated by IFS again.
Therefore, there is another answer:

  IFS=
  xmessage -nearmouse $message
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Newlines in environment variables

2005-05-29 Thread Ian Wienand
On Mon, May 30, 2005 at 11:30:48AM +1000, Peter Hardy wrote:
 xmessage -nearmouse $message

 Now, running this script with bash compresses $message to a single line,
 while zsh keeps the newlines intact. So I'm wondering how to achieve the
 same thing with bash.

Quote $message, as in

$ xmessage -nearmouse $message

-i
[EMAIL PROTECTED]
http://www.gelato.unsw.edu.au


signature.asc
Description: Digital signature
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html