Register
It is currently Fri Apr 18, 2014 4:16 pm

Very strange behaviour with a particular string


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Oct 23, 2012 8:18 am   
User avatar

Joined: Sun Nov 01, 2009 8:59 am
Posts: 23
Location: Try to guess!
Hi, came across this rather baffling behaviour today while writing a script:
Code:
steve@machn ~ $ echo $flags

steve@machn ~ $ flags="-r"
steve@machn ~ $ echo $flags
-r
steve@machn ~ $ flags="-r -e"
steve@machn ~ $ echo $flags
-r -e
steve@machn ~ $ flags="-e"
steve@machn ~ $ echo $flags

steve@machn ~ $

Even more bafflingly something seems to insert stray single-quotes in this line:
Code:
flags="-e \"ssh -p $port\""

so that it becomes (according to bash -x)
Code:
+ rsync -e '"ssh' -p '65555"'

obviously screwing everything up.
What am i missing here? @-)
Using GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)


Top
 Profile  
 PostPosted: Tue Oct 23, 2012 8:42 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 512
hi,

"I'm trying to put a command in a variable, but the complex cases always fail!" -> http://mywiki.wooledge.org/BashFAQ/050


Top
 Profile  
 PostPosted: Tue Nov 27, 2012 4:23 am   
User avatar

Joined: Sun Nov 01, 2009 8:59 am
Posts: 23
Location: Try to guess!
Thanks a lot, VERY useful wiki!


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP