Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Like /etc/rc.d/network, add the ability to put a '!' charact...
details: https://anonhg.NetBSD.org/src/rev/0fa483f98ca6
branches: trunk
changeset: 365876:0fa483f98ca6
user: brad <brad%NetBSD.org@localhost>
date: Sat Apr 30 13:48:09 2022 +0000
description:
Like /etc/rc.d/network, add the ability to put a '!' character as the
first character in /etc/gpio.conf and have the rest evaluated in a
shell. It is useful to be able to do actions after setting up gpio
pins or attaching gpioiic(4).
diffstat:
etc/rc.d/gpio | 19 +++++++++++++++----
share/man/man5/gpio.conf.5 | 5 ++++-
2 files changed, 19 insertions(+), 5 deletions(-)
diffs (55 lines):
diff -r 35d8e15632d2 -r 0fa483f98ca6 etc/rc.d/gpio
--- a/etc/rc.d/gpio Sat Apr 30 13:20:09 2022 +0000
+++ b/etc/rc.d/gpio Sat Apr 30 13:48:09 2022 +0000
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: gpio,v 1.1 2009/07/25 16:20:10 mbalmer Exp $
+# $NetBSD: gpio,v 1.2 2022/04/30 13:48:09 brad Exp $
#
# PROVIDE: gpio
@@ -18,10 +18,21 @@
if [ -f /etc/gpio.conf ]; then
echo "Configuring GPIO."
cat /etc/gpio.conf |
+ collapse_backslash_newline |
while read -r args; do
- args=${args%%#*} # strip comments
- test -z "$args" && continue
- /usr/sbin/gpioctl -q $args
+ case "$args" in
+ "!"*)
+ # Run arbitrary command in a subshell.
+ ( eval "${args#*!}" )
+ ;;
+ *)
+ (
+ args=${args%%#*} # strip comments
+ test -z "$args" && continue
+ /usr/sbin/gpioctl -q $args
+ )
+ ;;
+ esac
done
fi
}
diff -r 35d8e15632d2 -r 0fa483f98ca6 share/man/man5/gpio.conf.5
--- a/share/man/man5/gpio.conf.5 Sat Apr 30 13:20:09 2022 +0000
+++ b/share/man/man5/gpio.conf.5 Sat Apr 30 13:48:09 2022 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpio.conf.5,v 1.2 2009/08/01 13:14:40 mbalmer Exp $
+.\" $NetBSD: gpio.conf.5,v 1.3 2022/04/30 13:48:09 brad Exp $
.\"
.\" Copyright (c) 2009 Marc Balmer <marc%msys.ch@localhost>
.\" All rights reserved.
@@ -40,6 +40,9 @@
Lines starting with a hash
.Pq Sq #
and empty lines are ignored.
+If a line starts with
+.Sq \&! ,
+the rest of line will get evaluated as shell script fragment.
All other lines are passed to
.Xr gpioctl 8 .
.Sh FILES
Home |
Main Index |
Thread Index |
Old Index