delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/02/19/13:56:36

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.20030219104505.02baf960@pop3.cris.com>
X-Sender: rrschulz AT pop3 DOT cris DOT com
Date: Wed, 19 Feb 2003 10:56:44 -0800
To: cygwin AT cygwin DOT com
From: Randall R Schulz <rrschulz AT cris DOT com>
Subject: Re: Output of bash dirs command vs. emacs
In-Reply-To: <20030219140357.24864.qmail@web14507.mail.yahoo.com>
Mime-Version: 1.0

Nix,

Consider:

% help dirs
dirs: dirs [-clpv] [+N] [-N]
     Display the list of currently remembered directories.  Directories
     find their way onto the list with the `pushd' command; you can get
     back up through the list with the `popd' command.

     The -l flag specifies that `dirs' should not print shorthand versions
     of directories which are relative to your home directory.  This means
     that `~/bin' might be displayed as `/homes/bfox/bin'.  The -v flag
     causes `dirs' to print the directory stack with one entry per line,
     prepending the directory name with its position in the stack.  The -p
     flag does the same thing, but the stack position is not prepended.
     The -c flag clears the directory stack by deleting all of the elements.

     +N  displays the Nth entry counting from the left of the list shown by
         dirs when invoked without options, starting with zero.

     -N  displays the Nth entry counting from the right of the list shown by
         dirs when invoked without options, starting with zero.


An example:

% dirs -v
  0  /d/Program Files
  1  /c/SD/tau/src/tau/io
  2  /c/SD/tau/src/tau/fol
  3  /c/SD/tau/src/tau/tkb
  4  /c/SD/tau/src/tau/web

% dirs -v |sed -e 's/^ *[0-9]* *//'
/d/Program Files
/c/SD/tau/src/tau/io
/c/SD/tau/src/tau/fol
/c/SD/tau/src/tau/tkb
/c/SD/tau/src/tau/web

% dirs -v |sed -e 's/^ *[0-9]* *//' -e $'s/\([ \t&*(){}|"\'<>?]\)/\\\\\\1/g'
/d/Program\ Files
/c/SD/tau/src/tau/io
/c/SD/tau/src/tau/fol
/c/SD/tau/src/tau/tkb
/c/SD/tau/src/tau/web

% dirs -v |sed -e 's/^ *[0-9]* *//' -e $'s/^.*[ \t&*(){}|"\'<>?].*$/\'&\'/g'
'/d/Program Files'
/c/SD/tau/src/tau/io
/c/SD/tau/src/tau/fol
/c/SD/tau/src/tau/tkb
/c/SD/tau/src/tau/web


The character class show here as requiring escaping was haphazardly by 
scanning the keyboard. If you're going to embed this technique in a 
script or some elisp code in Emacs, I'd take the time to carefully sort 
out exactly which characters requires escaping or quoting.


Does that make "dirs" useful for your purposes?

None of this is really Cygwin-specific, just more likely to turn up 
under Windows.

Randall Schulz


At 06:03 2003-02-19, Ixnay Amenay wrote:

>The output of the 'dirs' builtin does not escape space characters:
>
>bash> dirs
>~/program files ~/src/emacs
>bash>
>
>This breaks the M-x dirs function of both cygwin emacs and NT emacs.
>
>I believe this to be a bash bug: There is no way for emacs (or 
>anything else) to parse the output of dirs and disambiguate "space 
>used as delimiter" vs. "space in the directory name".


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