[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl
From: |
Paul Eggert |
Subject: |
Re: [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl modules. |
Date: |
Tue, 04 Dec 2007 15:12:02 -0800 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Ralf Wildenhues <address@hidden> writes:
> +# $FILE_NAME
> +# shell_quote ($FILE_NAME)
> +# ------------------------
> +# If the string $S is a well-behaved file name, simply return it.
> +# If it contains white space, quotes, etc., quote it, and return
> +# the new string.
> +sub shell_quote($)
> +{
> + my ($s) = @_;
> + if ($s =~ m![^\w+/.,-]!)
> + {
> + # Convert each single quote to '\''
> + $s =~ s/\'/\'\\\'\'/g;
> + # Then single quote the string.
> + $s = "'$s'";
> + }
> + return $s;
> +}
A nit: if the goal is to quote only those file names requiring
quoting, then this quotes too often; e.g., it quotes @ in file names.
I think the only characters you should need to worry about in practice
are:
\t \n \r space ! " # $ % & ' ( ) * ; < > ? [ \ ^ ` | ~
- [PATCH 0/10] Whitespace robustness patch series, Ralf Wildenhues, 2007/12/04
- [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl modules., Ralf Wildenhues, 2007/12/04
- Re: [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl modules., Russ Allbery, 2007/12/04
- Re: [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl modules.,
Paul Eggert <=
- Re: [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl modules., Eric Blake, 2007/12/05
- Re: [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl modules., Ralf Wildenhues, 2007/12/06
- Re: [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl modules., Eric Blake, 2007/12/12
- Re: [PATCH 1/10] Proper file name escaping in Autoconf programs and Perl modules., Ralf Wildenhues, 2007/12/13
[PATCH 2/10] * lib/autom4te.in: Quote @address@hidden, Ralf Wildenhues, 2007/12/04
[PATCH 3/10] Fix Autotest for whitespace in `pwd`., Ralf Wildenhues, 2007/12/04
[PATCH 4/10] Proper config.status --file/--header and $srcdir escaping., Ralf Wildenhues, 2007/12/04