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).
This commit is contained in:
Benno Schulenberg 2024-04-14 12:01:03 +02:00
parent c695d49a86
commit c02aec557c
2 changed files with 2 additions and 2 deletions

View File

@ -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 " "

View File

@ -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"