[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Escaping special characters for *nix file path


Subject: Re: [xsl] Escaping special characters for *nix file path
From: Markus Abt <abt@xxxxxxxx>
Date: Sun, 29 Jul 2012 17:52:25 +0200

Wolfgang Laun wrote:
> A relatively safe way would be to enclose the path name in apostrophes
> (') and escape all contained apostrophes and backslashes with a
> backslash.

That my work in some shell, but not in bash, for example.
In bash, in a single-qouted argument, backslash is a normal character, 
not an escape character. As a consequence, the apostrohpe cannot 
be included directly, since it cannot be escaped.

Instead, the apostrophe has to be replaced by either
apos-backsl-apos-apos ('\'') or apos-quot-apos-qout-apos ('"'"'):

$ echo $SHELL
/bin/bash
$ touch 'a b"c$d!e?f&g*h\i'\''1'
$ touch 'a b"c$d!e?f&g*h\i'"'"'2'
$ ls -1
a b"c$d!e?f&g*h\i'1
a b"c$d!e?f&g*h\i'2

Markus


Current Thread