summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2021-04-02 16:02:54 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2021-04-07 19:16:33 +0000
commitc7b656fc7125adc5888ce934f1a3433da4b1bbc5 (patch)
tree49e8312426e202ac43295870edb0924a2e09242f
parent11326df80789c71d3ac24d5ff3da2c1c0617961a (diff)
downloadillumos-joyent-c7b656fc7125adc5888ce934f1a3433da4b1bbc5.tar.gz
13601 ksh shell lint misleading
13631 shell lint about variable expansion in arithmetic expressions is inscrutable Reviewed by: Robert Mustacchi <rm@fingolfin.org> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/contrib/ast/src/cmd/ksh93/data/lexstates.c3
-rw-r--r--usr/src/contrib/ast/src/cmd/ksh93/include/lexstates.h1
-rw-r--r--usr/src/contrib/ast/src/cmd/ksh93/sh/lex.c28
-rw-r--r--usr/src/contrib/ast/src/cmd/ksh93/sh/parse.c2
4 files changed, 32 insertions, 2 deletions
diff --git a/usr/src/contrib/ast/src/cmd/ksh93/data/lexstates.c b/usr/src/contrib/ast/src/cmd/ksh93/data/lexstates.c
index d4a3628130..01e56f5471 100644
--- a/usr/src/contrib/ast/src/cmd/ksh93/data/lexstates.c
+++ b/usr/src/contrib/ast/src/cmd/ksh93/data/lexstates.c
@@ -393,13 +393,14 @@ const char e_lexsyntax2[] = "syntax error: `%s' %s";
const char e_lexsyntax3[] = "syntax error at line %d: duplicate label %s";
const char e_lexsyntax4[] = "syntax error at line %d: invalid reference list";
const char e_lexsyntax5[] = "syntax error at line %d: `<<%s' here-document not contained within command substitution";
-const char e_lexwarnvar[] = "line %d: variable expansion makes arithmetic evaluation less efficient";
+const char e_lexwarnvar[] = "line %d: in '((%s))', using '$' is unnecessary, incurs a penalty and can introduce rounding errors.";
const char e_lexlabignore[] = "line %d: label %s ignored";
const char e_lexlabunknown[] = "line %d: %s unknown label";
const char e_lexobsolete1[] = "line %d: `...` obsolete, use $(...)";
const char e_lexobsolete2[] = "line %d: -a obsolete, use -e";
const char e_lexobsolete3[] = "line %d: '=' obsolete, use '=='";
const char e_lexobsolete4[] = "line %d: %s within [[...]] obsolete, use ((...))";
+const char e_lexobsolete4b[] = "line %d: [[... %s ...]] obsolete, use ((... %s ...))";
const char e_lexobsolete5[] = "line %d: set %s obsolete";
const char e_lexobsolete6[] = "line %d: `{' instead of `in' is obsolete";
const char e_lexnonstandard[] = "line %d: `&>file' is nonstandard -- interpreted as `>file 2>&1' for profile input only";
diff --git a/usr/src/contrib/ast/src/cmd/ksh93/include/lexstates.h b/usr/src/contrib/ast/src/cmd/ksh93/include/lexstates.h
index a078e35ecf..ff2ae696c1 100644
--- a/usr/src/contrib/ast/src/cmd/ksh93/include/lexstates.h
+++ b/usr/src/contrib/ast/src/cmd/ksh93/include/lexstates.h
@@ -139,6 +139,7 @@ extern const char e_lexobsolete1[];
extern const char e_lexobsolete2[];
extern const char e_lexobsolete3[];
extern const char e_lexobsolete4[];
+extern const char e_lexobsolete4b[];
extern const char e_lexobsolete5[];
extern const char e_lexobsolete6[];
extern const char e_lexnonstandard[];
diff --git a/usr/src/contrib/ast/src/cmd/ksh93/sh/lex.c b/usr/src/contrib/ast/src/cmd/ksh93/sh/lex.c
index c42c10604e..b517246167 100644
--- a/usr/src/contrib/ast/src/cmd/ksh93/sh/lex.c
+++ b/usr/src/contrib/ast/src/cmd/ksh93/sh/lex.c
@@ -1462,8 +1462,36 @@ breakloop:
default:
if(lp->lex.testop2)
{
+#ifdef __ASTUpstream__
if(lp->lexd.warn && (c&TEST_ARITH))
errormsg(SH_DICT,ERROR_warn(0),e_lexobsolete4,shp->inlineno,state);
+#else
+ if(lp->lexd.warn && (c&TEST_ARITH)) {
+ char *alt = NULL;
+
+ if (strcmp(state, "-eq") == 0)
+ alt = "==";
+ else if (strcmp(state, "-ne") == 0)
+ alt = "!=";
+ else if (strcmp(state, "-lt") == 0)
+ alt = "<";
+ else if (strcmp(state, "-gt") == 0)
+ alt = ">";
+ else if (strcmp(state, "-le") == 0)
+ alt = "<=";
+ else if (strcmp(state, "-ge") == 0)
+ alt = ">=";
+ if (alt != NULL) {
+ errormsg(SH_DICT, ERROR_warn(0),
+ e_lexobsolete4b,
+ shp->inlineno, state, alt);
+ } else {
+ errormsg(SH_DICT, ERROR_warn(0),
+ e_lexobsolete4,
+ shp->inlineno, state);
+ }
+ }
+#endif
if(c&TEST_PATTERN)
lp->lex.incase = 1;
else if(c==TEST_REP)
diff --git a/usr/src/contrib/ast/src/cmd/ksh93/sh/parse.c b/usr/src/contrib/ast/src/cmd/ksh93/sh/parse.c
index 49289784ea..d9100840f0 100644
--- a/usr/src/contrib/ast/src/cmd/ksh93/sh/parse.c
+++ b/usr/src/contrib/ast/src/cmd/ksh93/sh/parse.c
@@ -290,7 +290,7 @@ static Shnode_t *getanode(Lex_t *lp, struct argnod *ap)
else
{
if(sh_isoption(SH_NOEXEC) && (ap->argflag&ARG_MAC) && paramsub(ap->argval))
- errormsg(SH_DICT,ERROR_warn(0),e_lexwarnvar,lp->sh->inlineno);
+ errormsg(SH_DICT,ERROR_warn(0),e_lexwarnvar,lp->sh->inlineno, ap->argval);
t->ar.arcomp = 0;
}
return(t);