smdev

suckless mdev
git clone git://git.2f30.org/smdev
Log | Files | Refs | README | LICENSE

commit 7fd04dd5164ef69238418b90bc2bb7103f3bf529
parent f1a2e69e5a933bbe326b6065a867521bf61f65a7
Author: sin <sin@2f30.org>
Date:   Fri, 27 Feb 2015 22:45:37 +0000

Add updated simevent by emg

Diffstat:
Mbin/simevent | 16++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/bin/simevent b/bin/simevent @@ -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" {} +