Skip to content

Commit

Permalink
fix(lsinitrd.sh): handle filenames with special characters
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aafeijoo-suse committed Jan 31, 2023
1 parent eb75861 commit 1f84ff8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lsinitrd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "========================================================================"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f84ff8

Please sign in to comment.