Mail Archives: cygwin/2006/01/04/10:20:17
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 -