pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/pkglint



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat May  9 19:26:11 UTC 2020

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: mkline_test.go shell.go shell_test.go

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.643 -r1.644 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.80 -r1.81 pkgsrc/pkgtools/pkglint/files/mkline_test.go
cvs rdiff -u -r1.61 -r1.62 pkgsrc/pkgtools/pkglint/files/shell.go
cvs rdiff -u -r1.67 -r1.68 pkgsrc/pkgtools/pkglint/files/shell_test.go

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.643 pkgsrc/pkgtools/pkglint/Makefile:1.644
--- pkgsrc/pkgtools/pkglint/Makefile:1.643      Fri May  8 19:50:04 2020
+++ pkgsrc/pkgtools/pkglint/Makefile    Sat May  9 19:26:11 2020
@@ -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/}

Index: pkgsrc/pkgtools/pkglint/files/mkline_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.80 pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.81
--- pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.80   Sat Mar  7 23:35:35 2020
+++ pkgsrc/pkgtools/pkglint/files/mkline_test.go        Sat May  9 19:26:11 2020
@@ -799,8 +799,7 @@ func (s *Suite) Test_MkLine_VariableNeed
        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

Index: pkgsrc/pkgtools/pkglint/files/shell.go
diff -u pkgsrc/pkgtools/pkglint/files/shell.go:1.61 pkgsrc/pkgtools/pkglint/files/shell.go:1.62
--- pkgsrc/pkgtools/pkglint/files/shell.go:1.61 Thu Mar 26 07:02:44 2020
+++ pkgsrc/pkgtools/pkglint/files/shell.go      Sat May  9 19:26:11 2020
@@ -397,60 +397,6 @@ type ShellLineChecker struct {
        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 @@ func (ck *ShellLineChecker) CheckShellCo
                return
        }
 
-       ck.checkConditionalCd(program)
-
        walker := NewMkShWalker()
        walker.Callback.SimpleCommand = func(command *MkShSimpleCommand) {
                scc := NewSimpleCommandChecker(command, time, ck.mkline, ck.MkLines)
@@ -828,11 +772,6 @@ outer:
                                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.

Index: pkgsrc/pkgtools/pkglint/files/shell_test.go
diff -u pkgsrc/pkgtools/pkglint/files/shell_test.go:1.67 pkgsrc/pkgtools/pkglint/files/shell_test.go:1.68
--- pkgsrc/pkgtools/pkglint/files/shell_test.go:1.67    Thu Mar 26 07:02:44 2020
+++ pkgsrc/pkgtools/pkglint/files/shell_test.go Sat May  9 19:26:11 2020
@@ -602,32 +602,6 @@ func (s *Suite) Test_ShellLineChecker__s
        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 @@ func (s *Suite) Test_ShellLineChecker_ca
                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 @@ func (s *Suite) Test_ShellLineChecker_Ch
 
        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 @@ func (s *Suite) Test_ShellLineChecker_ch
                "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 @@ func (s *Suite) Test_ShellLineChecker_Ch
        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 @@ func (s *Suite) Test_ShellLineChecker_ch
 
        test(
                "$$(cat /bin/true)",
-               "WARN: module.mk:1: Invoking subshells via $(...) is not portable enough.")
+               nil...)
 
        test(
                "\"$$\"",



Home | Main Index | Thread Index | Old Index