Package: xdg-utils
Version: 1.1.0~rc1-2
Severity: wishlist
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hello,

I have just seen that xdg-screensaver uses several grep commands as conditions,
adding >/dev/null and 2>/dev/null redirections. Using grep's -q and -s options
would be advisable (and faster, as grep -q exits at the first match instead of
waiting for the end of file). Here is a patch that implements that.

Regards,

- -- 
Tanguy Ortolo

- -- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.0.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

xdg-utils depends on no packages.

Versions of packages xdg-utils recommends:
ii  libfile-mimeinfo-perl  <none>
ii  x11-utils              7.6+4 
ii  x11-xserver-utils      7.6+3 

Versions of packages xdg-utils suggests:
ii  gvfs-bin  1.8.2-2

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCgAGBQJOtn2aAAoJEOryzVHFAGgZkcsP/iLWTSmepEQ3msjJiinVHFh5
FQeN0rxVYuA5J0e+dVT6R7rLkRA0O33KpOOFU5Av4r01NA5hZgbeETs2J28eN1gm
BwgidbRjISLr5T0+hjPD/aFMB9N/7Iswx/Y3PJ6hOabGU8ykDldKIhBNeWi0pXLy
kSc39irmkjmQbugx9MsldskrlBDiv/rPeX88rC6jBtgAbsqstXRRuUoxDXTgn/MT
xqlonrWGn+awVuoRnKQ5sHbM50U6Hs+wsmZj54fSwOjmBZJTS1UK1cbDhPdTLeim
6YN7lYmNCBgObPnlosvuf9h8Gx0rFHdu8euOv/oc4U5Z0oSeTzk9kixw4ULPZBnR
sCfHfnjgLOTfC7UepDMYSzE5CS4tqiEGb7M+EH2qT5I0fjS5elD7/BbOGpbi29CX
/0V55bAuaViIBNbjxLJCBRg8mrAtkgzyhTgCGTh+3kieKXtM+1uv+/IqiQZWiOEL
kGYu558xHXn+mwH0GjA/4Ph51uRPxkgadEiPOupXiqGg2ckTxOCrJNPvnqwsrLwu
/diK/EEC92EMwaUgJIDuRns5f/tms7t0NNnuPYj4fUq1mDtwN9yh88dyiutGf9aF
TkO5cTD1tUssrnslf7Eu4KjvmDvHc6H1z8KfPhm4Eqjf9yhO4DVX0JWq6UgWkuEk
pgRKa0uZXnYALgi14Oee
=7toC
-----END PGP SIGNATURE-----
--- xdg-screensaver.orig	2011-11-06 13:08:02.043310783 +0100
+++ xdg-screensaver	2011-11-06 13:16:09.024684848 +0100
@@ -334,7 +334,7 @@
     if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
     elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
     elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
-    elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+    elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep -qs ' = \"xfce4\"$'; then DE=xfce;
     elif [ x"$DESKTOP_SESSION" = x"LXDE" ]; then DE=lxde;
     else DE=""
     fi
@@ -358,7 +358,7 @@
 }
 
 # Check if we can use "mv -T"
-if mv -T ... ... 2>&1 | grep '\.\.\.' > /dev/null ; then
+if mv -T ... ... 2>&1 | grep -q '\.\.\.' ; then
    # We can securely move files in /tmp with mv -T
    DEBUG 1 "mv -T available"
    MV="mv -T"
@@ -410,7 +410,7 @@
       fi
   fi
   if [ "$1" = "reset" ] ; then
-      if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
+      if xset -q | grep -qs 'DPMS is Enabled'; then
           xset dpms force on
       fi
   fi
@@ -443,7 +443,7 @@
 
   if [ "$1" = "suspend" ] ; then
       # Save DPMS state
-      if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
+      if xset -q | grep -qs 'DPMS is Enabled'; then
           test "${TMPDIR+set}" = set || TMPDIR=/tmp
           tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
           $MV "$tmpfile" "$screensaver_file.dpms"
@@ -459,7 +459,7 @@
   lockfile
   test "${TMPDIR+set}" = set || TMPDIR=/tmp
   tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
-  grep -v "$window_id:$xprop_pid\$" "$screensaver_file" > "$tmpfile" 2> /dev/null
+  grep -vs "$window_id:$xprop_pid\$" "$screensaver_file" > "$tmpfile"
   $MV "$tmpfile" "$screensaver_file"
   if [ ! -s "$screensaver_file" ] ; then
       rm "$screensaver_file"
@@ -475,9 +475,9 @@
 {
   lockfile # Obtain lockfile
   # Find the PID of the trackingprocess
-  xprop_pid=`grep "$window_id:" "$screensaver_file" 2> /dev/null | cut -d ':' -f 2`
+  xprop_pid=`grep -s "$window_id:" "$screensaver_file" | cut -d ':' -f 2`
   unlockfile # Free lockfile
-  if [ -n "$xprop_pid" ] && ps -p "$xprop_pid" 2> /dev/null | grep xprop > /dev/null; then
+  if [ -n "$xprop_pid" ] && ps -p "$xprop_pid" 2> /dev/null | grep -q xprop; then
      # Kill the tracking process
      kill -s TERM $xprop_pid
   fi
@@ -518,7 +518,7 @@
     IFS_save="$IFS"
     IFS=":"
     while read wid pid; do
-      if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
+      if ps -p "$pid" 2> /dev/null | grep -q xprop; then
         echo "$wid:$pid"
         if [ $wid = $window_id ] ; then
           already_tracked=0
@@ -790,7 +790,7 @@
     IFS_save="$IFS"
     IFS=":"
     while read wid pid; do
-      if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
+      if ps -p "$pid" 2> /dev/null | grep -q xprop; then
         echo "$wid:$pid"
       fi
     done

Reply via email to