You are here: PSPad forum > English discussion forum > correction for "UNIX shell script" syntax highlighter wanted

correction for "UNIX shell script" syntax highlighter wanted

#1 correction for "UNIX shell script" syntax highlighter wanted

Posted by: dirks | Date: 2014-01-24 16:13 | IP: IP Logged

Hi,

1. The "UNIX shell script" highlighter must be case sensitive!

All shell-internal commands are lowercase, so a variable named "TEST" or "Test" does not interfere with the shell command "test" - but the highlighter shows the "Test" and "TEST" variables in dark blue anyway. Rather annyoing... sad smiley

2. The "UNIX shell script" highlighter should have the "escaped string" setting, if possible only for double quoted strings!

A double quoted string like "She said \"Hi\"" stops being a double quoted string before the 'H' - that makes the highlighter falsely show the "Hi" as outside the string... sad smiley
Related problem: In single quoted strings, the '\' character does NOT escape a single quote, so for single quoted strings, the actual behavior of the syntax highlighter is correct.

3. If possible: Single and double quoted strings can span several lines in UNIX shell scripts, so it is perfectly legal to write:

NEWLINE="
" # A variable that contains just a line break

to get a line break within a shell variable - but the highlighter stops considering a string at the end of the line, so the comment seems to be within a string... It would be great if the syntax highlighter could (be told to) look for a closing single or double quote until the end of the file, like the shell does, otherwise it does not help with strings you forgot to close. sad smiley

All that said, I totally love PSpad (Version 4.7.5 (2450)) and use it every day, very often to edit shell-scripts or awk-scripts on a remote UNIX machine via the ftp feature - great feature! (Once in a while I need the Vim editor to find a "runaway string" because it has correct syntax highlighting for shell scripts, but I prefer PSpad very much!) smiling smiley smiling smiley smiling smiley

By the way - I created a syntax highlighter for awk. It has the same problem with strings spanning more than one line. Is anybody interested anyway?

Greetings from Germany
Dirk

Options: Reply | Quote | Up ^


#2 Re: correction for "UNIX shell script" syntax highlighter wanted

Posted by: pspad | Date: 2014-01-24 17:19 | IP: IP Logged

Thank you for description. I will try to fix it.
I suppose all Unix shell script keywords are written as lowercase, right?

Options: Reply | Quote | Up ^


#3 Re: correction for "UNIX shell script" syntax highlighter wanted

Posted by: vbr | Date: 2014-01-24 18:06 | IP: IP Logged

dirks:
By the way - I created a syntax highlighter for awk. It has the same problem with strings spanning more than one line. Is anybody interested anyway?

Hi,
just to add to the previous response, there seems to be an AWK highlighter as user highlighter already available (however, as I don't actually use it, I can't comment its functionality).

This, like many additional highlighters are available via:
Settings: Highlighters settings:
check [x] and select some of the <not assigned> items at the end of the list and select the needed item from "User highlighters" and save the dialog.

hth,
vbr

Options: Reply | Quote | Up ^


#4 Re: correction for "UNIX shell script" syntax highlighter wanted

Posted by: dirks | Date: 2014-01-27 11:28 | IP: IP Logged

pspad:
...
I suppose all Unix shell script keywords are written as lowercase, right?

Yes, that's right, they are. smiling smiley
(I believe because of that it became sort of a "tradition" that shell variables are (mostly) consisting of upper case letters.)

Hmm... It is an internal highlighter, so I believe I will need a new version of PSpad to see the corrections. How do I know which one? Will you tell me in this thread? Thank you in advance!

Options: Reply | Quote | Up ^


#5 Re: correction for "UNIX shell script" syntax highlighter wanted

Posted by: pspad | Date: 2014-01-27 11:41 | IP: IP Logged

I hope in the next developer build. I must appologize to all, but I am really busy, I will try to publish it as soon as possible

Options: Reply | Quote | Up ^


#6 Re: correction for "UNIX shell script" syntax highlighter wanted

Posted by: dirks | Date: 2014-01-27 11:50 | IP: IP Logged

vbr:
dirks:
By the way - I created a syntax highlighter for awk. It has the same problem with strings spanning more than one line. Is anybody interested anyway?

Hi,
just to add to the previous response, there seems to be an AWK highlighter as user highlighter already available (however, as I don't actually use it, I can't comment its functionality).

This, like many additional highlighters are available via:
Settings: Highlighters settings:
check [x] and select some of the <not assigned> items at the end of the list and select the needed item from "User highlighters" and save the dialog.

hth,
vbr

Right. I had mine in use for more than a year now and forgot about the existing one. The existing one has some errors in upper/lower case, mine is correct and has a few additional keywords and some comments. I hereby declare mine to be without any guarantee (not even for being useful) and freely available for any use:

;PSPad user HighLighter definition file
[Settings]
Name=AWK2 Script
HTMLGroup=0
FileType=*.awk
CommentString=
SharpComment=1
IndentChar=
UnIndentChar=
TabWidth=0
DoubleQuote=1
KeyWordChars=-_
CodeExplorer=ftUnknown
;
[KeyWords]
; predefined functions, must be lower case:
atan2=
close=
cos=
delete=
exp=
getline=
gsub=
index=
int=
length=
log=
match=
next=
nextfile=
print=
printf=
rand=
sin=
split=
sprintf=
sqrt=
srand=
sub=
substr=
system=
tolower=
toupper=
; in addition, nawk/gawk-only:
and=
asort=
asorti=
bindtextdomain=
compl=
dcgettext=
dcngettext=
fflush=
gensub=
lshift=
rshift=
strtonum=
mktime=
strftime=
systime=
xor=
;
[ReservedWords]
; these are only reserved when in all upper case:
BEGIN=
END=
; these are only reserved when in all lower case:
break=
continue=
do=
else=
exit=
for=
function=
if=
in=
return=
while=
; in addition, nawk/gawk-only:
func=
nextfile=
;
[KeyWords2]
; reserved variables, must be all upper case:
ARGC=
ARGIND=
ARGV=
ENVIRON=
FILENAME=
FNR=
FS=
NF=
NR=
RSTART=
RLENGTH=
OFS=
ORS=
OFMT=
RS=
SUBSEP=
CONVFMT=
; in addition, gawk-only:
ARGIND=
AWKPATH=
BINMODE=
ERRNO=
FIELDWIDTHS=
IGNORECASE=
LINT=
PROCINFO=
POSIXLY_CORRECT=
RT=
TEXTDOMAIN=
;
[KeyWords3]
; environment-variables for localization, all upper case:
LANG=
LC_ALL=
LC_COLLATE=
LC_CTYPE=
LC_MESSAGES=
LC_NUMERIC=
LC_TIME=
; environment-variable used by system() function, all upper case:
PATH=

It works best with uppercase/lowercase setting ticked/enabled, because it is perfectly legal to name a variable "Length" and it would not interfere with the predefined function "length" smiling smiley

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR