Mail Archives: cygwin/2003/01/24/01:32:22
Robert,
Here's what happened:
At 22:07 2003-01-23, Robert Mark Bram wrote:
>Howdy all!
>
>I am trying to write a little script that will allow me to "cd" to any
>directory in Cygwin by pasting in the Windows path.. Here is a screen dump
>of my work so far:
>
> $ function cdd () {
> > cd "`cygpath --unix "$*"`"
> > }
"$*" vs. "$@" -- The former always produces exactly one string (even if
there are no arguments to the shell procedure), if the shell procedure
had more than one argument, a space is inserted between each in the
resulting concatenated single argument. The latter form ("$@") produces
as many strings as there were arguments to the shell procedure
(including zero strings if there were no arguments to the shell
procedure) and nothing is added to the contents of those arguments.
> $ pwd
> /
>
> $ cdd C:\My Music
Here's what happens:
cd "`cygpath --unix "C:My Music"`"
I'm guessing your Cygwin root is the same as your C: drive root, so in
this case you more or less incidentally get the result you want because
your current directory was "/" (Cygwin) and "C:/" (Windows).
> $ pwd
> /cygdrive/c/My Music
>
> $ cdd C:\Rob\mcd3060\Tri32002\a2
> bash: cd: C:Robmcd3060Tri32002a2: No such file or directory
In this case, the unquoted backslashes essentially just disappear,
since in each case the character they precede is not special.
> $ pwd
> /cygdrive/c/My Music
>
> $
>
>Why does the first use work but not the second?
>
>*puzzled*
If you want to use native Windows directory names (including both the
drive prefix and the backslashes), you're not going get around
explicitly quoting those names every time. If you have forward slashes
(you won't get them from Windows Explorer, though), then you'll only
need to quote the argument when there are spaces or other shell special
characters, which is often enough.
>Any help would be appreciated!
>
>Rob
Randall Schulz
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -