π ~1 min read
Table of contents
Symptom & Impact
Custom service script fails at startup with bad substitution, preventing daemon launch after system boot.
Environment & Reproduction
service start immediately exits when script contains Bash-only parameter expansion under /bin/sh.
Root Cause Analysis
Scripts written for Bash are executed by default FreeBSD /bin/sh in rc.d, causing syntax incompatibility.
Quick Triage
Run sh -n script, enable set -x, and inspect shebang plus substitution expressions unsupported by POSIX sh.
Step-by-Step Diagnosis
Identify non-portable constructs and compare script behavior under sh and bash shells explicitly. image_ref=0

Solution – Primary Fix
Rewrite script to POSIX-compliant syntax or set an explicit bash shebang with dependency availability checks. image_ref=1
Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

Solution – Alternative Approaches
Wrap complex startup logic in tested helper binaries and keep rc.d scripts minimal and portable.
Verification & Acceptance Criteria
Script passes sh -n validation and service starts cleanly via rc.d during reboot testing.
Rollback Plan
Reinstate previous working rc.d script version and defer advanced logic until portability fixes are complete.
Prevention & Hardening
Enforce shellcheck in CI and require POSIX compatibility reviews for all rc.d managed scripts.
Related Errors & Cross-Refs
Related errors include not found function syntax, arithmetic expansion failures, and unset variable exits.
Related tutorial: View the step-by-step tutorial for freebsd-12.
View all freebsd-12 tutorials on the Tutorials Hub β
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
Consult man sh, man rc.subr, and FreeBSD rc.d scripting conventions.
Need Expert Help?
If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today β we respond within one business day.