Register
It is currently Mon Sep 22, 2014 2:12 am

command with double quotes.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sat Nov 06, 2010 8:03 pm   

Joined: Wed Nov 26, 2008 7:43 pm
Posts: 50
Location: Texas
Hi everyone.. I want to make an alternative command
for 'cd' because when I'm using bash on windows.. I often
have the problems of having to convert windows
style paths to unix style paths..

So far I have the following function but I have
to insert quotes around the path myself. How can I make it
so that I don't have to insert the double quotes when
I call this function

cdp() { cd `cygpath.exe -u "$1"`; }

Ted


Top
 Profile  
 PostPosted: Sun Nov 07, 2010 3:31 am   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
afflictedd2 wrote:
Code:
cdp() { cd `cygpath.exe -u "$1"`; }

When you use "$1" as a parameter to 'cd' to, well... you will only use the first parameter of whatever you use on the commandline.
So yeah, you will have to use quotes around paths with spaces to make it 1 argument. This is normal behaviour and what you use with the normal 'cd' as well.
You could use "$@" to use all the arguments on the commandline to pass to your new 'cd' command.


Top
 Profile  
 PostPosted: Sun Nov 07, 2010 12:56 pm   

Joined: Wed Nov 26, 2008 7:43 pm
Posts: 50
Location: Texas
well my problem here really is more with cygpath

I understand that cd .. will need quotes if the path contains spaces, but
cygpath always needs quotes: This for example doesn't work:

cygpath.exe -u C:\Users\Viper\Documents

and this does:

cygpath.exe -u "C:\Users\Viper\Documents"

I hate putting those quotes, I am just wondering if
it is possible to make it so that the function I call does
not require me to put the quotes.

Ted.


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 3 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:  


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