Shell Quoting. Was: Shell tips and tricks

Steven W. Orr steveo at syslang.net
Mon Oct 8 09:29:41 EDT 2007


On Sunday, Oct 7th 2007 at 12:27 -0000, quoth Ben Scott:

=>On 10/7/07, Steven W. Orr <steveo at syslang.net> wrote:
=>
=>> I got a million of 'em ;-)
=>
=>  So keep going!  I'm trying to encourage the sharing of information, 
=>here.  :)

Ok. For starters. Let me tell you about my technique for Shell Minimal 
Quoting. This is not new stuff, it's just a programming technique I 
consistently use.

foo=bar                 # No quotes needed
echo $foo               # Also none needed if you *know* that foo has 
			# non-null value
baz='Hello there'       # Don't use double quotes. No iterpolation.
qaz="$baz $foo and grill" # Interpolation needs double quotes.

Use none when it's not needed. Use single when no interpolation is 
required. Only use double quotes when needed.

(Similiarly, I never use parens in C in a sizeof construct if the arg is a 
variable.

typedef foo bar;

printf( "sizeof foo = %ld\n", sizeof(foo) );
printf( "sizeof bar = %ld\n", sizeof bar );
)

(BTW, I can be really exciting at parties.)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


More information about the gnhlug-discuss mailing list