delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/12/04/10:57:48

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <5.2.0.9.2.20021204075549.026419a8@pop3.cris.com>
X-Sender: rrschulz AT pop3 DOT cris DOT com
Date: Wed, 04 Dec 2002 07:58:41 -0800
To: cygwin AT cygwin DOT com
From: Randall R Schulz <rrschulz AT cris DOT com>
Subject: RE: Bash puzzle: Spaces, environment variables and tab
completion
In-Reply-To: <NCBBIHCHBLCMLBLOBONKCEAPDJAA.g.r.vansickle@worldnet.att.ne
t>
References: <5 DOT 2 DOT 0 DOT 9 DOT 2 DOT 20021203225120 DOT 02462148 AT pop3 DOT cris DOT com>
Mime-Version: 1.0

At 23:23 2002-12-03, Gary R. Van Sickle wrote:
> > James,
> >
> > You're swimming upstream. Don't do that. Use the system in accordance with
> > its design.
> >
>
>Don't listen to him Jim!  You pound anything long enough, it'll give!

Ordinarily, I agree, but on this point, you'd have to re-write the shell's 
parser to change how variable expansion occurs (and then provide some sort 
of "de-quote" to give the alternate behavior when that's needed).


> > Parsing command lines based on white-space separators fundamentally entails
> > the need for escaping or quoting when those separator characters are to be
> > included in the arguments and not used to separate them.
> >
>
>If you do:
>
>  VAR='path with spaces'
>
>it tab-completes to:
>
>  path\ with\ spaces\
>
>which is what James wants.

As I said.


>Unfortunately, and as I neglected to note in my last post since I didn't 
>realize it til just now, you can't:
>
>  cd $VAR
>
>you must still
>
>  cd "$VAR"
>
>Ah well, more pounding I guess...

Pound away, you won't get it to work.

But hey! Prove me wrong.

Randall Schulz
Mountain View, CA USA



> > At 22:09 2002-12-03, James Shaw wrote:
> > >Hi everyone,
> > >
> > >I have been using cygwin for several months, and there is something that I
> > >haven't been able to figure out how to do: effectively use spaces in bash
> > >environment variables.
> > >
> > >I realize this is basically a bash question and isn't Cygwin specific, but
> > >I'm sure more Cygwin users have to deal with spaces in bash than the
> > >typical bash user.
> > >
> > >What I want to do is define an environment
> > >variable so I can easily cd or ls.  E.g.
> > >% PF="/cygdrive/c/Program Files"
> > >% cd $PF
> > >% ls $PF/Games
> > >% ls $PF/G<tab completion!>
> > >
> > >The above is close, I can
> > >% cd "$PF"; ls "$PF"/Games; and even
> > >ls "$PF"/G<tab> however, the quotes are clunky.
> > >
> > >My kludge to avoid the quotes is:
> > >
> > >% PF2="/cygdrive/c/Program?Files"
> > >
> > >which allows cd $PF; ls $PF/Games,
> > >
> > >but stops bash in its tracks on tab completion.
> > >
> > >Since I would find this very handy, I've spent some time on trying to make
> > >this work.  I've tried various quoting schemes, but with no luck.
> > >
> > >So, I ask the list:
> > >         Can you define $PF so that cd $PF;
> > >         ls $PF/Games; and ls $PF/G<tab> all work???
> >
> > No, No and Yes. Just leave the spaces in the variable and command
> > completion will insert the necessary escapes when expanding it. If the
> > variable references is already inside a double-quote (even if it's not yet
> > closed on the right), then command completion will not insert the 
> backslashes.
> >
> >
> > >I usually like to puzzle these out for myself, but in this case, I'm 
> stumped.
> > >
> > >Thanks for your help,
> > >James
> >
> >
> > Randall Schulz
> > Mountain View, CA USA
> >
> >
> > --
> > 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/
> >
>
>--
>Gary R. Van Sickle
>Brewer.  Patriot.


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


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019