From: Antonio Alvarez Feijoo Date: Wed, 4 Jan 2023 15:51:12 +0000 (+0100) Subject: fix(lsinitrd.sh): handle filenames with special characters X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f84ff882fe272ef0185a284eee82e89735c833d;p=thirdparty%2Fdracut.git fix(lsinitrd.sh): handle filenames with special characters Printing and unpacking of specific files passed as arguments does not work if their filenames contain special characters with a hexadecimal character escape (\x), which is often the case for systemd device units. --- diff --git a/lsinitrd.sh b/lsinitrd.sh index eaadc7623..b6f436cb4 100755 --- a/lsinitrd.sh +++ b/lsinitrd.sh @@ -176,6 +176,8 @@ extract_files() { for f in "${!filenames[@]}"; do [[ $nofileinfo ]] || echo "initramfs:/$f" [[ $nofileinfo ]] || echo "========================================================================" + # shellcheck disable=SC2001 + [[ $f == *"\\x"* ]] && f=$(echo "$f" | sed 's/\\x.\{2\}/????/g') $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --to-stdout "$f" 2> /dev/null ((ret += $?)) [[ $nofileinfo ]] || echo "========================================================================" @@ -219,7 +221,9 @@ list_squash_content() { unpack_files() { if ((${#filenames[@]} > 0)); then for f in "${!filenames[@]}"; do - $CAT "$image" 2> /dev/null | cpio -id --quiet $verbose $f + # shellcheck disable=SC2001 + [[ $f == *"\\x"* ]] && f=$(echo "$f" | sed 's/\\x.\{2\}/????/g') + $CAT "$image" 2> /dev/null | cpio -id --quiet $verbose "$f" ((ret += $?)) done else