DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 27th December 2009
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,116
Thanked 182 Times in 149 Posts
Default ksh quote or no quote whitespace madness

The program:
Code:
#!/bin/sh
    
THIS='   aa
bb
    cc
dd
ee
ff'
    
THAT="   zz
yy
    xx
ww
"

echo \"THIS: [\${THIS}]\"    
echo -------------------
echo "THIS: [${THIS}]"

echo

echo THIS: [\${THIS}]
echo -------------------
echo THIS: [${THIS}]

echo

echo \"THAT: [\${THAT}]\"
echo -------------------
echo "THAT: [${THAT}]"

echo

echo THAT: [\${THAT}]
echo -------------------
echo THAT: [${THAT}]
A run and the output
Code:
$ sh this-that
"THIS: [${THIS}]"
-------------------
THIS: [   aa
bb
    cc
dd
ee
ff]

THIS: [${THIS}]
-------------------
THIS: [ aa bb cc dd ee ff]

"THAT: [${THAT}]"
-------------------
THAT: [   zz
yy
    xx
ww
]

THAT: [${THAT}]
-------------------
THAT: [ zz yy xx ww ]
Who can explain?
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
 

Tags
echo, quotes, sh whitespace

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
interrupt storm and irq madness siffland FreeBSD General 5 23rd October 2009 05:16 AM
escape single quote in sed gosha Programming 5 9th March 2009 10:22 AM


All times are GMT. The time now is 12:23 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick