Register
It is currently Thu Feb 22, 2018 12:44 am

How do I pass double quotes to a shell command?


All times are UTC


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sat Mar 23, 2013 8:28 pm   
New Member

Joined: Sat Mar 23, 2013 8:18 pm
Posts: 1
Hi everyone,

I know this is probably more simple than I'm making it out to be. Here's my dilemma though. I'm creating a script that automatically configures your computer to use bzr (Ubuntu's version of Git) and download a project. One of the requirements for bzr is to identify yourself, so you can receive credit for your work. The format of the command is like this:

Code:
bzr whoami "Your Name <youremailaddress>"


In my script, I have this

Code:
echo "Please enter your name and email address now: The format should be \"Your Name <[email protected]>\" without the quotes."
read inname
bzr whoami "$inname"


My question is this: Should I have
Code:
bzr whoami '"'$inname'"'
instead, so that it passes the ""'s along with the name and email address? I tried adding the quotes to the input (having the user put "Your Name <youremailaddress>" instead of just Your Name <youremailaddress>), but that passes the quotes as part of the name/email. Or, since I'm passing in a string anyhow, would I even need the quotes at all?

In other words, would
Code:
bzr whoami '"'$inname'"'


or
Code:
bzr whoami $inname


be correct instead of what I have now?

Thanks and have a great day.:)
Patrick.


Top
 Profile  
 PostPosted: Mon Mar 25, 2013 6:25 am   
Linux Guru
User avatar

Joined: Sat Apr 03, 2004 12:39 am
Posts: 12346
Location: Clinton Township, Michigan
If you do want to pass the quotation marks, using \ to escape the " is certainly one legitimate way to go. I have no idea whether the quotes are needed or not since I have not used the tool you are using. All I can suggest is that if quotes are needed, then escape them, and using \ will accomplish that purpose.

_________________
Brian Masinick
Distros: MX-16, antiX, Debian


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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


Powered by phpBB © 2012 phpBB Group
© 2003 - 2012 USA LINUX USERS GROUP