View Single Post
  #1   (View Single Post)  
Old 27th December 2009
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,131
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