delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/01/04/10:20:17

X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Eric Blake <ebb9 AT byu DOT net>
Subject: Re: chere problem with directories with single quote marks
Date: Wed, 4 Jan 2006 15:18:53 +0000 (UTC)
Lines: 38
Message-ID: <loom.20060104T155620-3@post.gmane.org>
References: <20060103210307 DOT 63140 DOT qmail AT web53410 DOT mail DOT yahoo DOT com> <43BBD542 DOT 90604 AT byu DOT net>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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

Eric Blake <ebb9 <at> byu.net> writes:
> 
> Sorry, but I don't know ANY portable construct that works in all 4 cygwin
> shells (ash, bash, zsh, and pdksh).
> 
> Plus there is still the matter of translating a valid command line into a
> registry entry that Windows can parse; I don't know if you can embed
> newlines, and without embedded newlines, a here-doc will not work.
> 
> All I can do is wish you good luck.

I put a bit more thought into it, and verified that the following works from 
the command line in all four shells (in other words, since here-docs inside 
command substitutions are buggy, put the here-doc in a function and just call 
the function in the command substitution):

$ cd /tmp; mkdir -p 'a'\''b`c)d  e$f'
$ foo(){ cat<<\EOF
> a'b`c)d  e$f
> EOF
> };cd "$(foo)"
$ pwd
/tmp/a'b`c)d  e$f
$

One other worry - a here-doc will fail if the delimiter happens to match the 
filename.  When Windows expands %L, is it to an absolute pathname?  Otherwise, 
I am afraid that if you use EOF, chere would fail to work in a directory named 
EOF.  But even that can be worked around - since " is not valid in Windows 
filenames, you could use this as an unambiguous here-doc inside your function:

cat<<\"
%L
"

--
Eric Blake




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.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