public inbox for initramfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dracut-functions.sh: avoid tokenizing ldconfig output with 'read'
@ 2014-12-23 21:03 Lubomir Rintel
       [not found] ` <1419368590-2052-1-git-send-email-lkundrak-NGH9Lh4a5iE@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Lubomir Rintel @ 2014-12-23 21:03 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Lubomir Rintel

The space does not separate the elements reliably, spaces can be
embedded in parenthesized expressions too:

  libgmpxx.so.4 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmpxx.so.4
  libgmp.so.10 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmp.so.10

This results in dracut creating '0x0000000004000000' and '=>'
directories in the initramfs image.
---
 dracut-functions.sh | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/dracut-functions.sh b/dracut-functions.sh
index 410960d..37ddca2 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -104,17 +104,7 @@ fi
 
 ldconfig_paths()
 {
-    local a i
-    declare -A a
-    for i in $(
-        ldconfig -pN 2>/dev/null | grep -F '=>' | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | while read a b c d; do
-            d=${d%/*}
-            printf "%s\n" "$d";
-        done
-    ); do
-        a["$i"]=1;
-    done;
-    printf "%s\n" ${!a[@]}
+    ldconfig -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
 }
 
 # Detect lib paths
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dracut-functions.sh: avoid tokenizing ldconfig output with 'read'
       [not found] ` <1419368590-2052-1-git-send-email-lkundrak-NGH9Lh4a5iE@public.gmane.org>
@ 2015-01-08 15:36   ` Harald Hoyer
  0 siblings, 0 replies; 2+ messages in thread
From: Harald Hoyer @ 2015-01-08 15:36 UTC (permalink / raw)
  To: Lubomir Rintel, initramfs-u79uwXL29TY76Z2rM5mHXA

On 23.12.2014 22:03, Lubomir Rintel wrote:
> The space does not separate the elements reliably, spaces can be
> embedded in parenthesized expressions too:
> 
>   libgmpxx.so.4 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmpxx.so.4
>   libgmp.so.10 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmp.so.10
> 
> This results in dracut creating '0x0000000004000000' and '=>'
> directories in the initramfs image.
> ---
>  dracut-functions.sh | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/dracut-functions.sh b/dracut-functions.sh
> index 410960d..37ddca2 100755
> --- a/dracut-functions.sh
> +++ b/dracut-functions.sh
> @@ -104,17 +104,7 @@ fi
>  
>  ldconfig_paths()
>  {
> -    local a i
> -    declare -A a
> -    for i in $(
> -        ldconfig -pN 2>/dev/null | grep -F '=>' | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | while read a b c d; do
> -            d=${d%/*}
> -            printf "%s\n" "$d";
> -        done
> -    ); do
> -        a["$i"]=1;
> -    done;
> -    printf "%s\n" ${!a[@]}
> +    ldconfig -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
>  }
>  
>  # Detect lib paths
> 

Thanks! pushed

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-08 15:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-23 21:03 [PATCH] dracut-functions.sh: avoid tokenizing ldconfig output with 'read' Lubomir Rintel
     [not found] ` <1419368590-2052-1-git-send-email-lkundrak-NGH9Lh4a5iE@public.gmane.org>
2015-01-08 15:36   ` Harald Hoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox