Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update to 20.1.5



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2c43ecc82e04
branches:  trunk
changeset: 431153:2c43ecc82e04
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat May 09 19:26:11 2020 +0000

description:
pkgtools/pkglint: update to 20.1.5

Changes since 20.1.4:

No more wrong warnings about the Solaris /bin/sh. These warnings had been
there for 14 years, preventing pkgsrc developers from using the $$(...)
command substitution and negation in shell conditions.

https://mail-index.netbsd.org/pkgsrc-changes/2020/05/01/msg212194.html

diffstat:

 pkgtools/pkglint/Makefile             |   4 +-
 pkgtools/pkglint/files/mkline_test.go |   3 +-
 pkgtools/pkglint/files/shell.go       |  61 -------------------------
 pkgtools/pkglint/files/shell_test.go  |  83 ++--------------------------------
 4 files changed, 10 insertions(+), 141 deletions(-)

diffs (244 lines):

diff -r 67005f0bfab1 -r 2c43ecc82e04 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat May 09 19:14:16 2020 +0000
+++ b/pkgtools/pkglint/Makefile Sat May 09 19:26:11 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.643 2020/05/08 19:50:04 rillig Exp $
+# $NetBSD: Makefile,v 1.644 2020/05/09 19:26:11 rillig Exp $
 
-PKGNAME=       pkglint-20.1.4
+PKGNAME=       pkglint-20.1.5
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 67005f0bfab1 -r 2c43ecc82e04 pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Sat May 09 19:14:16 2020 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Sat May 09 19:26:11 2020 +0000
@@ -799,8 +799,7 @@
        MkLineChecker{mklines, mklines.mklines[2]}.Check()
 
        // Don't suggest to use ${AWK:Q}.
-       t.CheckOutputLines(
-               "WARN: xpi.mk:2: Invoking subshells via $(...) is not portable enough.")
+       t.CheckOutputEmpty()
 }
 
 // LDFLAGS (and even more so CPPFLAGS and CFLAGS) may contain special
diff -r 67005f0bfab1 -r 2c43ecc82e04 pkgtools/pkglint/files/shell.go
--- a/pkgtools/pkglint/files/shell.go   Sat May 09 19:14:16 2020 +0000
+++ b/pkgtools/pkglint/files/shell.go   Sat May 09 19:26:11 2020 +0000
@@ -397,60 +397,6 @@
        checkVarUse bool
 }
 
-func (ck *ShellLineChecker) checkConditionalCd(list *MkShList) {
-       if trace.Tracing {
-               defer trace.Call0()()
-       }
-
-       getSimple := func(list *MkShList) *MkShSimpleCommand {
-               if len(list.AndOrs) == 1 {
-                       if len(list.AndOrs[0].Pipes) == 1 {
-                               if len(list.AndOrs[0].Pipes[0].Cmds) == 1 {
-                                       return list.AndOrs[0].Pipes[0].Cmds[0].Simple
-                               }
-                       }
-               }
-               return nil
-       }
-
-       checkConditionalCd := func(cmd *MkShSimpleCommand) {
-               if NewStrCommand(cmd).Name == "cd" {
-                       ck.Errorf("The Solaris /bin/sh cannot handle \"cd\" inside conditionals.")
-                       ck.Explain(
-                               "When the Solaris shell is in \"set -e\" mode and \"cd\" fails, the",
-                               "shell will exit, no matter if it is protected by an \"if\" or the",
-                               "\"||\" operator.")
-               }
-       }
-
-       // TODO: It might be worth reversing the logic, like this:
-       //  walker.Callback.Simple = { if inside if.cond || loop.cond { ... } }
-       walker := NewMkShWalker()
-       walker.Callback.If = func(ifClause *MkShIf) {
-               for _, cond := range ifClause.Conds {
-                       if simple := getSimple(cond); simple != nil {
-                               checkConditionalCd(simple)
-                       }
-               }
-       }
-       walker.Callback.Loop = func(loop *MkShLoop) {
-               if simple := getSimple(loop.Cond); simple != nil {
-                       checkConditionalCd(simple)
-               }
-       }
-       walker.Callback.Pipeline = func(pipeline *MkShPipeline) {
-               if pipeline.Negated {
-                       ck.Warnf("The Solaris /bin/sh does not support negation of shell commands.")
-                       ck.Explain(
-                               "The GNU Autoconf manual has many more details of what shell",
-                               "features to avoid for portable programs.",
-                               "It can be read at:",
-                               "https://www.gnu.org/software/autoconf/manual/autoconf.html#Limitations-of-Builtins";)
-               }
-       }
-       walker.Walk(list)
-}
-
 func (ck *ShellLineChecker) checkSetE(list *MkShList, index int) {
        if trace.Tracing {
                defer trace.Call0()()
@@ -733,8 +679,6 @@
                return
        }
 
-       ck.checkConditionalCd(program)
-
        walker := NewMkShWalker()
        walker.Callback.SimpleCommand = func(command *MkShSimpleCommand) {
                scc := NewSimpleCommandChecker(command, time, ck.mkline, ck.MkLines)
@@ -828,11 +772,6 @@
                                ck.checkShVarUsePlain(atom, checkQuoting)
 
                        case atom.Type == shtSubshell:
-                               ck.Warnf("Invoking subshells via $(...) is not portable enough.")
-                               ck.Explain(
-                                       "The Solaris /bin/sh does not know this way to execute a command in a subshell.",
-                                       "Please use backticks (`...`) as a replacement.")
-
                                // Early return to avoid further parse errors.
                                // As of December 2018, it might be worth continuing again since the
                                // shell parser has improved in 2018.
diff -r 67005f0bfab1 -r 2c43ecc82e04 pkgtools/pkglint/files/shell_test.go
--- a/pkgtools/pkglint/files/shell_test.go      Sat May 09 19:14:16 2020 +0000
+++ b/pkgtools/pkglint/files/shell_test.go      Sat May 09 19:26:11 2020 +0000
@@ -602,32 +602,6 @@
        t.CheckOutputEmpty()
 }
 
-func (s *Suite) Test_ShellLineChecker_checkConditionalCd(c *check.C) {
-       t := s.Init(c)
-
-       t.SetUpTool("ls", "", AtRunTime)
-       t.SetUpTool("printf", "", AtRunTime)
-       t.SetUpTool("wc", "", AtRunTime)
-       mklines := t.NewMkLines("Makefile",
-               MkCvsID,
-               "pre-configure:",
-               "\t${RUN} while cd ..; do printf .; done",
-               "\t${RUN} while cd .. && cd ..; do printf .; done", // Unusual, therefore no warning.
-               "\t${RUN} if cd ..; then printf .; fi",
-               "\t${RUN} ! cd ..",
-               "\t${RUN} if cd ..; printf 'ok\\n'; then printf .; fi",
-               "\t${RUN} if cd .. | wc -l; then printf .; fi",  // Unusual, therefore no warning.
-               "\t${RUN} if cd .. && cd ..; then printf .; fi") // Unusual, therefore no warning.
-
-       mklines.Check()
-
-       t.CheckOutputLines(
-               "ERROR: Makefile:3: The Solaris /bin/sh cannot handle \"cd\" inside conditionals.",
-               "ERROR: Makefile:5: The Solaris /bin/sh cannot handle \"cd\" inside conditionals.",
-               "WARN: Makefile:6: The Solaris /bin/sh does not support negation of shell commands.",
-               "WARN: Makefile:8: The exitcode of \"cd\" at the left of the | operator is ignored.")
-}
-
 func (s *Suite) Test_ShellLineChecker_checkSetE__simple_commands(c *check.C) {
        t := s.Init(c)
 
@@ -721,15 +695,14 @@
                nil...)
 
        test("socklen=$$(expr 16)",
-               "WARN: Makefile:3: Invoking subshells via $(...) is not portable enough.",
                "WARN: Makefile:3: Please switch to \"set -e\" mode before using a semicolon "+
                        "(after \"socklen=$$(expr 16)\") to separate commands.")
 
        test("socklen=$$(expr 16 || true)",
-               "WARN: Makefile:3: Invoking subshells via $(...) is not portable enough.")
+               nil...)
 
        test("socklen=$$(expr 16 || ${TRUE})",
-               "WARN: Makefile:3: Invoking subshells via $(...) is not portable enough.")
+               nil...)
 
        test("${ECHO_MSG} \"Message\"",
                nil...)
@@ -1257,8 +1230,10 @@
 
        ck.CheckShellCommandLine(ck.mkline.ShellCommand())
 
-       t.CheckOutputLines(
-               "WARN: filename.mk:1: Invoking subshells via $(...) is not portable enough.")
+       // Up to 2020-05-09, pkglint had warned that $(...) were not portable
+       // enough. The shell used in devel/bmake can handle these subshell
+       // command substitutions though.
+       t.CheckOutputEmpty()
 }
 
 func (s *Suite) Test_ShellLineChecker_CheckShellCommandLine__install_dir(c *check.C) {
@@ -1365,39 +1340,6 @@
                "WARN: Makefile:4: The shell command \"ls\" should not be hidden.")
 }
 
-func (s *Suite) Test_ShellLineChecker_CheckShellCommand__cd_inside_if(c *check.C) {
-       t := s.Init(c)
-
-       t.SetUpVartypes()
-       t.SetUpTool("echo", "ECHO", AtRunTime)
-       mklines := t.NewMkLines("Makefile",
-               MkCvsID,
-               "",
-               "\t${RUN} if cd /bin; then echo \"/bin exists.\"; fi")
-
-       mklines.Check()
-
-       t.CheckOutputLines(
-               "ERROR: Makefile:3: The Solaris /bin/sh cannot handle \"cd\" inside conditionals.")
-}
-
-func (s *Suite) Test_ShellLineChecker_CheckShellCommand__negated_pipe(c *check.C) {
-       t := s.Init(c)
-
-       t.SetUpVartypes()
-       t.SetUpTool("echo", "ECHO", AtRunTime)
-       t.SetUpTool("test", "TEST", AtRunTime)
-       mklines := t.NewMkLines("Makefile",
-               MkCvsID,
-               "",
-               "\t${RUN} if ! test -f /etc/passwd; then echo \"passwd is missing.\"; fi")
-
-       mklines.Check()
-
-       t.CheckOutputLines(
-               "WARN: Makefile:3: The Solaris /bin/sh does not support negation of shell commands.")
-}
-
 func (s *Suite) Test_ShellLineChecker_CheckShellCommand__subshell(c *check.C) {
        t := s.Init(c)
 
@@ -1547,17 +1489,6 @@
        t.CheckOutputEmpty()
 }
 
-func (s *Suite) Test_ShellLineChecker_CheckWord__dollar_subshell(c *check.C) {
-       t := s.Init(c)
-
-       ck := t.NewShellLineChecker("\t$$(echo output)")
-
-       ck.CheckWord(ck.mkline.ShellCommand(), false, RunTime)
-
-       t.CheckOutputLines(
-               "WARN: filename.mk:1: Invoking subshells via $(...) is not portable enough.")
-}
-
 func (s *Suite) Test_ShellLineChecker_CheckWord__PKGMANDIR(c *check.C) {
        t := s.Init(c)
 
@@ -1633,7 +1564,7 @@
 
        test(
                "$$(cat /bin/true)",
-               "WARN: module.mk:1: Invoking subshells via $(...) is not portable enough.")
+               nil...)
 
        test(
                "\"$$\"",



Home | Main Index | Thread Index | Old Index