|
| 1 | +#!/bin/sh |
| 2 | +# Ensure cp handles dirs with non-UTF8 names when using recursive copy with dot |
| 3 | +# This test covers the case where a directory name contains non-UTF8 bytes |
| 4 | + |
| 5 | +# Copyright (C) 2026 Free Software Foundation, Inc. |
| 6 | + |
| 7 | +# This program is free software: you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU General Public License as published by |
| 9 | +# the Free Software Foundation, either version 3 of the License, or |
| 10 | +# (at your option) any later version. |
| 11 | + |
| 12 | +# This program is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +# GNU General Public License for more details. |
| 16 | + |
| 17 | +# You should have received a copy of the GNU General Public License |
| 18 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src |
| 21 | +print_ver_ cp |
| 22 | + |
| 23 | +non_utf8_dir=$(bad_unicode) |
| 24 | +mkdir "$non_utf8_dir" target \ |
| 25 | + || skip_ 'bad unicode not supported in shell or file system' |
| 26 | + |
| 27 | +# Create some test files in the non-UTF8 directory |
| 28 | +touch "$non_utf8_dir"/file1 "$non_utf8_dir"/file2 || framework_failure_ |
| 29 | + |
| 30 | +for loc in C "$LOCALE_FR" "$LOCALE_FR_UTF8"; do |
| 31 | + test -z "$loc" && continue |
| 32 | + export LC_ALL="$loc" |
| 33 | + |
| 34 | + # Test: copy contents of non-UTF8 directory using /. syntax |
| 35 | + # This should work without panicking or erroring |
| 36 | + cp -r "$non_utf8_dir"/. target || fail=1 |
| 37 | + |
| 38 | + # Verify the files were copied correctly |
| 39 | + rm target/file1 || fail=1 |
| 40 | + rm target/file2 || fail=1 |
| 41 | + |
| 42 | + # Verify original files still exist |
| 43 | + test -f "$non_utf8_dir"/file1 || fail=1 |
| 44 | + test -f "$non_utf8_dir"/file2 || fail=1 |
| 45 | +done |
| 46 | + |
| 47 | +Exit $fail |
0 commit comments