Date: Wed, 19 Feb 2025 02:45:32 GMT From: Cy Schubert <cy@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: ed9712f89435 - main - var_run: Clean up style Message-ID: <202502190245.51J2jW9q030606@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=ed9712f8943573136fa92a0e61c8e7c10952eeb0 commit ed9712f8943573136fa92a0e61c8e7c10952eeb0 Author: Cy Schubert <cy@FreeBSD.org> AuthorDate: 2024-11-26 15:16:22 +0000 Commit: Cy Schubert <cy@FreeBSD.org> CommitDate: 2025-02-19 02:42:34 +0000 var_run: Clean up style Clean up style and make more consistent. Replace test with if-then-else to make the script more legible. Replace the call to dirname with the shell %/* operator avoiding a fork & exec. Reorder the test for $var_run_autosave before the test for /var/run on tmpfs. This avoids gratuitously scanning the mount table for a tmpfs /var/run. Initial concept by and in discussion with: Harry Schmalzbauer <freebsd@omnilan.de> No functional change intended. MFC after: 2 weeks Differnential revision: https://reviews.freebsd.org/D47773 --- libexec/rc/rc.d/var_run | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libexec/rc/rc.d/var_run b/libexec/rc/rc.d/var_run index f76a06ab9f5a..9a3732f593b6 100755 --- a/libexec/rc/rc.d/var_run +++ b/libexec/rc/rc.d/var_run @@ -21,26 +21,30 @@ load_rc_config $name var_run_svcj="NO" _var_run_load() { - test -f ${var_run_mtree} && - mtree -U -i -q -f ${var_run_mtree} -p /var/run > /dev/null + if [ -f "${var_run_mtree}" ] ; then + mtree -U -i -q -f "${var_run_mtree}" -p /var/run > /dev/null + fi } _var_run_save() { - if [ ! -d $(dirname ${var_run_mtree}) ]; then - mkdir -p $(dirname ${var_run_mtree}) + if ! [ -d "${var_run_mtree%/*}" ]; then + mkdir -p "${var_run_mtree%/*}" fi - mtree -dcbj -p /var/run > ${var_run_mtree} + mtree -dcbj -p /var/run > "${var_run_mtree}" } _var_run_start() { - df -ttmpfs /var/run > /dev/null 2>&1 && + if df -ttmpfs /var/run > /dev/null 2>&1; then _var_run_load + fi } _var_run_stop() { - df -ttmpfs /var/run > /dev/null 2>&1 && - checkyesno var_run_autosave && + if checkyesno var_run_autosave; then + if df -ttmpfs /var/run > /dev/null 2>&1; then _var_run_save + fi + fi } run_rc_command "$1"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502190245.51J2jW9q030606>