Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

disable backslash escape for command line parameters

29 views
Skip to first unread message

Wenhua Zhao

unread,
Nov 23, 2009, 10:35:02 PM11/23/09
to
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

WANG Cong

unread,
Nov 24, 2009, 8:11:57 AM11/24/09
to
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 \'.

Will Renkel

unread,
Nov 25, 2009, 7:15:35 AM11/25/09
to
xiyou.w...@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.

---------------------------------------------------------------

bb

unread,
Dec 7, 2009, 10:57:02 AM12/7/09
to

Escape \ with an extra \
tr "[:upper:]\\" "[:lower:]/"


/bb

Kaz Kylheku

unread,
Dec 9, 2009, 12:34:32 AM12/9/09
to
On 2009-11-24, Wenhua Zhao <whz...@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.

0 new messages