commit c02aec557c752a98929193db4ea2a236b7c8f25a
parent c695d49a866f4c1a1a7a237d0a57970fb89b2801
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 14 Apr 2024 12:01:03 +0200
syntax: makefile, sh: recognize also a fresh Makefile and fresh .profile
When opening a nonexistent file with nano, it likely consists of only a
name without any path component, and thus without any slash. So when a
file regex checks for a slash, it should check also for start-of-string.
This fixes https://savannah.gnu.org/bugs/?65591.
Problem existed for the Makefile since version 2.9.8, commit 22663f8a,
and for .profile since version 3.0, commit 4a268678 (but earlier, nano
did not recognize .profile files at all).
Diffstat:
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/syntax/makefile.nanorc b/syntax/makefile.nanorc
@@ -1,6 +1,6 @@
## Syntax highlighting for Makefiles.
-syntax makefile "(/((GNU)?m|M)akefile[^/]*$|\.(make|mk)$)"
+syntax makefile "(^|/)((GNU)?m|M)akefile[^/]*$|\.(make|mk)$"
magic "makefile script"
tabgives " "
diff --git a/syntax/sh.nanorc b/syntax/sh.nanorc
@@ -1,6 +1,6 @@
## Syntax highlighting for Bourne shell scripts.
-syntax sh "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
+syntax sh "(\.sh|(^|/|\.)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|(/etc/|(^|/)\.)profile)$"
header "^#!.*/((env[[:blank:]]+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox[[:blank:]]+sh|openrc-run|runscript)\>"
header "-\*-.*shell-script.*-\*-"
magic "(POSIX|Bourne-Again) shell script.*text"