Re: Bash syntax highlighting: Quoted text in comments
Benno Schulenberg <[email protected]>
| Newsgroups | gmane.editors.nano.general |
|---|---|
| Message-ID | <[email protected]> |
Hello Michael,
Op 17-02-18 om 04:29 schreef Michael Siegel:
> I've found that nano has kind of an annoying way of highlighting quoted
> text within comments in Bash scripts.
>
> While the comments themselves are colored in cyan, quoted text within
> them will be given the standard string color, which is bright yellow.
>
> For example, try this:
>
> #!/bin/bash
>
> # Let's see if this won't happen.
>
> What you'll get is "# Let" in cyan, "'s see if this won'" in yellow and
> the rest in cyan again.
>
> I suppose this is a known issue. Maybe it has already been fixed in
> versions newer than the one I'm using (2.7.4). If not, what's the
> problem and is someone trying to fix it?
Thanks for pointing this out.
In general, it cannot be fixed. Nano does not do a full parse of the
script -- it simply uses regexes to color certain patterns. This means
that either you get quoted things in comments highlighted as strings,
or you get the part of a string after " #" highlighted as a comment.
The first option has been chosen.
You could change the order of the Comments and Strings commands
("color cyan" and "color brightyellow") in /usr/share/nano/sh.nanorc.
But that has the disadvantage of getting overwritten upon the next
update of nano.
Better would be to add in your nanorc file:
extendsyntax sh color cyan "(^|[[:space:]])#.*$"
That will make sure that comments are always colored in cyan.
But... maybe a point could be made that quotes in comments are more
common than space plus hash in strings? What do you think? Do you
have a large set of scripts that you can grep?
(I now see that the order of comment and string highlighting was
changed in the beginning of 2014, from nano-2.3.2 onwards. Maybe
that swap should be turned back?)
Benno
_______________________________________________
Help-nano mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-nano
signature.asc
(application/pgp-signature, 801 B)
-----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJaiVFSAAoJEA0o1NKgrOiEssEP/3iLtO+hl/UeMw8JQpWkUG4J V9mC3lqG5q1HiuWEDBLKp+ueQnK+WjQi77++gxGvaxdQUCsK0fzW5JyNPlOd8qt2 NnSF/uOAQNfV5ByjQMKqtWbcdLjHwDuczd5RljxQt4dMsesRIkAGUPcExWalcuYj YDRu2L+nlL+uo5Fulz3/j5rr2PLiPO2XA5EqPeoPjVkuM//h3MYbXOL5dKIsYlLv Ai1V2HG0iwe4xQ/PLC+wDZqUbPsG9J28JQbfpAmi0jbPbBG99QK7X4Ucg3ltkpWP AA36twZPYcCE7lpopPhPpwiS/P51LJACPOwuqYVmFY3csUChVBx0OzE3M+qqNqjm l6JJkLC8NqjsBEeUM/UBC3x6aP+HmdnB1GCulyZrNgG17MEzFWYPy/6eZQrxkv9q UKZa/O2xLYqYKPjv4R3E2zeO4xQyMMBH8OHiVjNauHUNKg070JkA9lxuTZ3gIjM8 SoySHJoWnWCxdJPMmpynyTpydSIyY50jwfHA5c5Sr2ENdvVqGRq2iZQzAcftXvYz alQhVSOlQxLgSUwPvRQEVzIdyT9YluM2NJX32bTW4McWdOR0eUMnXbZAV71IyYE2 erpeH+i3HW58iHYFx8qlAcbsqCGXzsqf2atTPYnFjCNfzxT+1UNWGBLeUBAZnrSI RkpO1PM41K3ekeZGd6P0 =wd5w -----END PGP SIGNATURE-----