2008-03-01 Benoit Sigoure <tsuna@lrde.epita.fr>
+ Be nice with file systems that don't handle unusual characters.
+ * tests/atlocal.in (func_sanitize_file_name)
+ (func_sanitize_dir_name): New shell functions.
+ * tests/tools.at (autom4te and whitespace in file names)
+ (autotools and whitespace in file names): Use them.
+ * tests/torture.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS):
+ Cover more potentially problemtic file names. Use the new
+ functions.
+
Properly handle funny file names for headers in config.status.
The test suite did not cover this bug because the code was not
quoting properly the arguments of `rm -f' (which "fails" silently)
# We need to know if sh -n is ok.
ac_cv_sh_n_works='@ac_cv_sh_n_works@'
+
+# Check whether the underlying system can manage some unusual
+# symbols in file names.
+unsupported_fs_chars=
+for c in '\\' '"' '<' '>' '*' '?' '|'
+do
+ touch "t$c" 2>/dev/null
+ test -f "t$c" && rm -f "t$c" && continue
+ # $c cannot be used in a file name.
+ unsupported_fs_chars=$unsupported_fs_chars$c
+done
+if test -z "$unsupported_fs_chars"; then
+ func_sanitize_file_name () { echo "$@"; }
+else
+ func_sanitize_file_name () { echo "$@" | tr -d "$unsupported_fs_chars"; }
+fi
+
+# Can we create directories with trailing whitespaces in their name?
+rm -rf 'tdir /'
+mkdir 'tdir ' && touch 'tdir /tfile' 2>/dev/null
+if test -f 'tdir /tfile'; then
+ func_sanitize_dir_name () { echo "$@"; }
+ rm -rf 'tdir /'
+else
+ func_sanitize_dir_name () { echo "$@" | sed 's/ *$//'; }
+fi
x=
export x
rm -f a b
-# the first one omits special characters and trailing spaces,
-# which are not w32 safe.
for funny in \
'with funny '\'' $x & #! name' \
'with funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock
do
+ funny=`func_sanitize_file_name "$funny"`
file=" file $funny"
outfile="$file out "
- dir=" dir $funny"
+ dir=`func_sanitize_dir_name " dir $funny"`
cachedir=" cache$dir"
TMPDIR=" tmp$dir"
export TMPDIR
x=
export x
rm -f a b
-# the first one omits special characters that are not w32 safe.
for funny in \
'with funny '\'' $x & #! name ' \
'with funny \ '\'' \'\'' " <a >b * ? name '
do
+ funny=`func_sanitize_file_name "$funny"`
file=" file $funny"
- dir=" dir $funny"
+ dir=`func_sanitize_dir_name " dir $funny"`
TMPDIR=" tmp$dir"
export TMPDIR
AT_CHECK([grep ac_write_fail config.status], [1])
# Check that --file and --header accept funny file names
-file='file with funny \ '\'' \'\'' $ & #!*? name'
-cat >"$file.in" <<'END'
+
+x=
+export x
+for file in \
+ 'with funny '\'' $x & #! name' \
+ 'file with funny \ '\'' \'\'' $ & #!*? name' \
+ 'with funny \ '\'' \'\'' " <a >b & * ? name ' # "restore font-lock
+do
+ # The function func_sanitize_file_name comes from tools.at
+ file=`func_sanitize_file_name "$file"`
+ cat >"$file.in" <<'END'
OK
END
-# skip if we cannot create such a file
-AT_CHECK([test -f "$file.in" || exit 77])
-AT_CHECK([./config.status "--file=$file:$file.in"],
- [0], [ignore])
-AT_CHECK([grep OK "$file"], [], [OK
+ AT_CHECK([./config.status "--file=$file:$file.in"],
+ [0], [ignore])
+ AT_CHECK([grep OK "$file"], [], [OK
])
-AT_CHECK([./config.status "--header=$file:$file.in"],
- [0], [ignore])
-# Run the same test a 2nd time to see that config.status does not recreate
-# the header (regression test)
-AT_CHECK([./config.status "--header=$file:$file.in"],
- [0], [config.status: creating file with funny \ ' \' $ & #!*? name
-config.status: file with funny \ ' \' $ & #!*? name is unchanged
+ AT_CHECK([./config.status "--header=$file:$file.in"],
+ [0], [ignore])
+ # Run the same test a 2nd time to see that config.status does not recreate
+ # the header (regression test)
+ AT_CHECK_NOESCAPE([./config.status "--header=$file:$file.in"],
+ [0], [config.status: creating $file
+config.status: $file is unchanged
])
-AT_CHECK([grep ' & ' "$file"], [],
-[/* file with funny \ ' \' $ & #!*? name. Generated from file with funny \ ' \' $ & #!*? name.in by configure. */
+ AT_CHECK_NOESCAPE([grep ' & ' "$file"], [],
+[/* $file. Generated from $file.in by configure. */
])
-AT_CHECK([grep OK "$file"], [], [OK
+ AT_CHECK([grep OK "$file"], [], [OK
])
+done
AT_CLEANUP