git: 50cf49f6011f - stable/13 - service(8): Allow for passing no arguments to the service script

From: Mateusz Piotrowski <0mp_at_FreeBSD.org>
Date: Fri, 23 May 2025 08:45:18 UTC
The branch stable/13 has been updated by 0mp:

URL: https://cgit.FreeBSD.org/src/commit/?id=50cf49f6011f861c1824303e26fff1655fc3e54a

commit 50cf49f6011f861c1824303e26fff1655fc3e54a
Author:     sd@mostnet.ru <sd@mostnet.ru>
AuthorDate: 2025-05-09 14:48:27 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2025-05-23 08:43:58 +0000

    service(8): Allow for passing no arguments to the service script
    
    Currently, service(8) requires the user to provide a command to the
    rc service script. For example,
    
        service cron
    
    does not even run the cron rc service script but
    instead shows the usage message of service(8).
    
    This patch makes it so running the rc service script with no arguments
    via service(8) is closer to running the rc service script directly
    (e.g., /etc/rc.d/cron).
    
    Long story short, for most of the rc service scripts this change means
    that running "service FOO" now shows the usage message of FOO instead of
    the usage message of service(8).
    
    PR:             255115
    Reviewed by:    bnovkov, christos, imp, lme, markj
    Approved by:    bnovkov (mentor), christos (mentor), markj (mentor)
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D47328
    
    (cherry picked from commit 7ffedfe14ca85aa3474980092a732d4e49309c62)
---
 usr.sbin/service/service.8  | 4 ++--
 usr.sbin/service/service.sh | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/service/service.8 b/usr.sbin/service/service.8
index c367f3bc12a6..51a5ec665cbd 100644
--- a/usr.sbin/service/service.8
+++ b/usr.sbin/service/service.8
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 9, 2021
+.Dd May 9, 2025
 .Dt SERVICE 8
 .Os
 .Sh NAME
@@ -47,7 +47,7 @@
 .Op Fl j Ar jail
 .Op Fl v
 .Ar script
-.Ar command
+.Op Ar command
 .Sh DESCRIPTION
 The
 .Nm
diff --git a/usr.sbin/service/service.sh b/usr.sbin/service/service.sh
index ca08e08ecd62..63f8eb006ad6 100755
--- a/usr.sbin/service/service.sh
+++ b/usr.sbin/service/service.sh
@@ -151,7 +151,7 @@ if [ -n "$RCORDER" ]; then
 	exit 0
 fi
 
-if [ $# -gt 1 ]; then
+if [ $# -gt 0 ]; then
 	script=$1
 	shift
 else