[arch-projects] [mkinitcpio][PATCH 22/26] lsinitcpio: follow symlinks only when necessary

Dave Reisner d at falconindy.com
Mon Sep 26 21:22:23 EDT 2011


If the image we're pointing to is a symlink, show the resolution as part
of the name in -a's output.

Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
 lsinitcpio |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lsinitcpio b/lsinitcpio
index 95c0500..4cf4889 100755
--- a/lsinitcpio
+++ b/lsinitcpio
@@ -86,7 +86,7 @@ readonly NC BOLD BLUE GREEN RED YELLOW
 [[ -f $image ]] || die "$image: No such file"
 
 # read compression type
-case "$(file -b "$image")" in
+case "$(file -Lb "$image")" in
     @(data|LZMA)*) compress=lzma ;;
     gzip*) compress=gzip ;;
     bzip2*) compress=bzip2 ;;
@@ -129,7 +129,9 @@ if (( analyze )); then
     done
 
     # print results
-    msg 'Image: %s' "$(readlink -e "$image")"
+    imagename=$image
+    [[ -L $image ]] && imagename+=" -> $(readlink -e "$image")"
+    msg 'Image: %s' "$imagename"
     msg 'Kernel: %s' "${kernver:-unknown}"
 
     if [[ $compress ]]; then
-- 
1.7.6.4



More information about the arch-projects mailing list