[hackers] [smdev] Add updated simevent by emg || sin

From: <git_AT_suckless.org>
Date: Fri, 27 Feb 2015 23:46:00 +0100 (CET)

commit f8534bbc2f38111b8756c91c6f41ccd557dec2a1
Author: sin <sin_AT_2f30.org>
Date: Fri Feb 27 22:45:37 2015 +0000

    Add updated simevent by emg

diff --git a/bin/simevent b/bin/simevent
index ec99927..0ab4c4c 100755
--- a/bin/simevent
+++ b/bin/simevent
_AT_@ -3,16 +3,12 @@
 # Simulate add/remove events by writing directly
 # into the uevent files.
 
-if [ -z $1 ]; then
- echo "usage: $(basename $0) add|remove" 2>&1
+if [ "$#" -ne 1 ] || [ "$1" != add ] && [ "$1" != remove ]; then
+ # warning: can't trust $0, better off just hard coding the name
+ # echo "usage: simevent add|remove" 1>&2
+ printf "usage: %s add|remove\n" "${0##*/}" 1>&2
         exit 1
 fi
 
-ev=$1
-for i in $(find /sys/devices -type f); do
- f=$(basename $i)
- if [ "$f" = "dev" ]; then
- d=$(dirname $i)
- echo $ev > $d/uevent
- fi
-done
+find /sys/devices -type f -path '*/dev' -exec \
+ sh -c 'for f do printf %s\\n "$0" > "${f%/*}"/uevent; done' "$1" {} +
Received on Fri Feb 27 2015 - 23:46:00 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 27 2015 - 23:48:08 CET