From: Wenhua Zhao on 23 Nov 2009 22:35 Hi all, Is it possible to disable backslash escape for command line parameters? I am trying to define a function, wcd, in Cygwin to cd to windows pathname. If I type wcd C:\Windows The function will execute cd /cygdrive/c/Windows Here is my function function wcd { cd /cygdrive/`echo $1 | tr -d ':' | tr [A-Z\] [a-z/]` } The problem with this function is that I must single quote the parameter wcd 'C:\Windows' Is there any way to escape the single quote? Thanks, Wenhua
From: WANG Cong on 24 Nov 2009 08:11 On Mon, 23 Nov 2009 19:35:02 -0800, Wenhua Zhao wrote: > Hi all, > > Is it possible to disable backslash escape for command line parameters? > > I am trying to define a function, wcd, in Cygwin to cd to windows > pathname. If I type > > wcd C:\Windows > > The function will execute > > cd /cygdrive/c/Windows > > Here is my function > > function wcd { > cd /cygdrive/`echo $1 | tr -d ':' | tr [A-Z\] [a-z/]` > } > > The problem with this function is that I must single quote the parameter > > wcd 'C:\Windows' What's wrong with using single quotes for you? And window$ is designed like that, get used to it. > > Is there any way to escape the single quote? Why do you want to *escape* single quotes here? Yes, you can use "'" to get a single quote, or simply \'.
From: Will Renkel on 25 Nov 2009 07:15 xiyou.wangcong(a)gmail.com wrote: >On Mon, 23 Nov 2009 19:35:02 -0800, Wenhua Zhao wrote: > >> Hi all, >> >> Is it possible to disable backslash escape for command line parameters? >> >> I am trying to define a function, wcd, in Cygwin to cd to windows >> pathname. If I type >> >> wcd C:.Windows >> >> The function will execute >> >> cd /cygdrive/c/Windows >> >> Here is my function >> >> function wcd { >> cd /cygdrive/`echo $1 | tr -d ':' | tr [A-Z.] [a-z/]` >> } >> >> The problem with this function is that I must single quote the parameter >> >> wcd 'C:.Windows' > >What's wrong with using single quotes for you? And window$ is designed >like that, get used to it. > >> >> Is there any way to escape the single quote? > >Why do you want to *escape* single quotes here? > >Yes, you can use "'" to get a single quote, or simply .'. Dont see the need for what you are doing. did you try just enter cd C:Windows? Works for me -- --------------------------------------------------------------- Will Renkel Wheaton, Ill. ---------------------------------------------------------------
From: bb on 7 Dec 2009 10:57 On 2009-11-24 04:35, Wenhua Zhao wrote: > Hi all, > > Is it possible to disable backslash escape for command line parameters? > > I am trying to define a function, wcd, in Cygwin to cd to windows > pathname. If I type > > wcd C:\Windows > > The function will execute > > cd /cygdrive/c/Windows > > Here is my function > > function wcd { > cd /cygdrive/`echo $1 | tr -d ':' | tr [A-Z\] [a-z/]` > } > > The problem with this function is that I must single quote the parameter > > wcd 'C:\Windows' > > Is there any way to escape the single quote? > > Thanks, > Wenhua Escape \ with an extra \ tr "[:upper:]\\" "[:lower:]/" /bb
From: Kaz Kylheku on 9 Dec 2009 00:34 On 2009-11-24, Wenhua Zhao <whzhao(a)gmail.com> wrote: > Hi all, > > Is it possible to disable backslash escape for command line parameters? > > I am trying to define a function, wcd, in Cygwin to cd to windows > pathname. If I type > > wcd C:\Windows You idiot! :) Firstly, the Windows operating system accepts either forward or backslashes. The path C:/Windows works just fine in Cygwin. Has it ooccured to you to just try: $ ls c:/windows In fact, newsflash: every Microsoft operating system between MS-DOS and now has supported forward /and/ backslashes as path separators, at the same time. The lack of support for forward slashes is a disease of badly written application-level software, including the command interpreter. The operating system itself supports it. In early MS-DOS versions, there was a little-known variable or option in the COMMAND.COM interpreter (can't remember which) by which you could tell it what character to recognize as path separator. You could run the interpreter in a forward slash mode. This feature disappeared, leaving the command interpreter hard-coded to backslashes. > The problem with this function is that I must single quote the parameter > > wcd 'C:\Windows' You can escape a backslash by doubling it. Not that you need to, but you can type C:\\Windows.
|
Pages: 1 Prev: 10 Reasons Why YOU Should Join Us Next: Swap the appearance order of two lines if needed. |