ls to stat patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I was randomly looking through the git repository and came across
modules.d/95resume/resume.sh and its comment about not liking the use of
ls.  I modified it to use stat instead, and since stat has been in
coreutils since at least late 2005, I assume it's safe to use.

Thanks



diff -rN -U 5 dracut-001.orig/modules.d/95resume/resume.sh dracut-001/modules.d/95resume/resume.sh
--- dracut-001.orig/modules.d/95resume/resume.sh	2009-09-02 09:55:35.000000000 -0400
+++ dracut-001/modules.d/95resume/resume.sh	2009-09-03 02:29:27.000000000 -0400
@@ -1,8 +1,5 @@
 #!/bin/sh
 [ -s /.resume -a -b "$resume" ] && {
-    # parsing the output of ls is Bad, but until there is a better way...
-    ls -lH "$resume" | ( 
-	read x x x x maj min x;
-	echo "${maj%,}:$min"> /sys/power/resume)
+    stat -c '%t:%T' "$resume" > /sys/power/resume
     >/.resume
 }
diff -rN -U 5 dracut-001.orig/modules.d/99base/install dracut-001/modules.d/99base/install
--- dracut-001.orig/modules.d/99base/install	2009-09-02 09:55:35.000000000 -0400
+++ dracut-001/modules.d/99base/install	2009-09-03 02:00:35.000000000 -0400
@@ -1,8 +1,8 @@
 #!/bin/bash
 dracut_install mount mknod mkdir modprobe pidof sleep chroot \
-    sed ls flock cp mv dmesg rm ln
+    sed ls flock cp mv dmesg rm ln stat
 if [ ! -e "${initdir}/bin/sh" ]; then
     dracut_install bash
     (ln -s bash "${initdir}/bin/sh" || :)
 fi
 # install our scripts and hooks


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux