git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Solaris and sed: Too many commands, last: s/\n//

From
JWJeffrey Walton <noloader@gmail.com>
Date
Mar 12, 2019, 01:55 UTC
Message-ID
<CAH8yC8=PKro1_WW=wJQoVHC88cziJPfgkHh6jNKOUxeFn3KVsQ@mail.gmail.com>
In-Reply-To
<CAH8yC8kHhhWA+ONv17LdLpvy6ubH3CTvJ6=ehP5MQLi_=n1=bQ@mail.gmail.com>
On Mon, Mar 11, 2019 at 9:07 PM Jeffrey Walton <noloader@gmail.com> wrote:
Show 31 quoted lines
>
> On Mon, Mar 11, 2019 at 6:28 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> >
> > On Mon, Mar 11, 2019 at 05:43:55PM -0400, Jeffrey Walton wrote:
> > > On Mon, Mar 11, 2019 at 5:15 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > > > On Mon, Mar 11, 2019 at 4:32 PM Jeffrey Walton <noloader@gmail.com> wrote:
> > > > > I enabled self tests for Solaris. Solaris has some anemic utilities so
> > > > > I put /usr/gnu/bin first on-path.
> > > >
> > > > The first question is if you are really running GNU 'sed'? My guess is
> > > > "no, it's still picking up Solaris's 'sed'".
> > >
> > > I believe so. After modifying PATH, command -v returns:
> > >
> > >     Solaris tools:
> > >          sed: /usr/gnu/bin/sed
> > >          awk: /usr/gnu/bin/awk
> > >         grep: /usr/gnu/bin/grep
> > >
> > > (This was added to my scripts to confirm).
> > ...
> >
> > > Maybe Git would benefit from SED, AWK and GREP variables like PERL.
> >
> > Very possibly.
>
> Another potential workaround is to use Perl. Perl is already a
> prerequisite, it get passed to the test gear through PERL_PATH, and it
> avoids Solaris' anemic tools.
>
> Sadly my Perl sucks. You would be disappointed if I tried to whip up a patch.

Oh man, you're using GNU make. I thought Git was using that anemic Posix Make. See attached.

I think Solaris provides an older gawk. Is this an easier problem:
    awk: chainlint.sed:88: :squash
    awk: chainlint.sed:88: ^ syntax error
    awk: chainlint.sed:91:  s/\\\n//
    awk: chainlint.sed:91:    ^ backslash not last character on line
    Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
    Usage: awk [POSIX or GNU style options] [--] 'program' file ...
Jeff

--- t/Makefile +++ t/Makefile

@@ -11,11 +11,25 @@
 TEST_SHELL_PATH ?= $(SHELL_PATH)
 PERL_PATH ?= /usr/bin/perl
 TAR ?= $(TAR)
+AWK ?= $(AWK)
+SED ?= $(SED)
+GREP ?= $(GREP)
 RM ?= rm -f
 PROVE ?= prove
 DEFAULT_TEST_TARGET ?= test
 TEST_LINT ?= test-lint
 
+# Fix Solaris tools. GNU tools at /usr/gnu/bin. Posix tools /usr/xpg4/bin.
+ifneq ($(wildcard /usr/gnu/bin/grep),)
+  GREP := /usr/gnu/bin/grep
+endif
+ifneq ($(wildcard /usr/gnu/bin/sed),)
+  SED := /usr/gnu/bin/sed
+endif
+ifneq ($(wildcard /usr/gnu/bin/awk),)
+  SED := /usr/gnu/bin/awk
+endif
+
 ifdef TEST_OUTPUT_DIRECTORY
 TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
 CHAINLINTTMP = $(TEST_OUTPUT_DIRECTORY)/chainlinttmp
@@ -35,7 +49,7 @@
 TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
 THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
 CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
-CHAINLINT = sed -f chainlint.sed
+CHAINLINT = $(SED) -f chainlint.sed
 
 all: $(DEFAULT_TEST_TARGET)
 
@@ -44,8 +58,8 @@
 
 failed:
 	@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
-		grep -l '^failed [1-9]' *.counts | \
-		sed -n 's/\.counts$$/.sh/p') && \
+		$(GREP) -l '^failed [1-9]' *.counts | \
+		$(SED) -n 's/\.counts$$/.sh/p') && \
 	test -z "$$failed" || $(MAKE) $$failed
 
 prove: pre-clean check-chainlint $(TEST_LINT)
@@ -73,7 +87,7 @@
 	err=0 && \
 	for i in $(CHAINLINTTESTS); do \
 		$(CHAINLINT) <chainlint/$$i.test | \
-		sed -e '/^# LINT: /d' >'$(CHAINLINTTMP_SQ)'/$$i.actual && \
+		$(SED) -e '/^# LINT: /d' >'$(CHAINLINTTMP_SQ)'/$$i.actual && \
 		diff -u chainlint/$$i.expect '$(CHAINLINTTMP_SQ)'/$$i.actual || err=1; \
 	done && exit $$err
 
@@ -81,7 +95,7 @@
 	test-lint-filenames
 
 test-lint-duplicates:
-	@dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
+	@dups=`echo $(T) | tr ' ' '\n' | $(SED) 's/-.*//' | sort | uniq -d` && \
 		test -z "$$dups" || { \
 		echo >&2 "duplicate test numbers:" $$dups; exit 1; }
 
@@ -97,7 +111,7 @@
 	@# We do *not* pass a glob to ls-files but use grep instead, to catch
 	@# non-ASCII characters (which are quoted within double-quotes)
 	@bad="$$(git -c core.quotepath=true ls-files 2>/dev/null | \
-			grep '["*:<>?\\|]')"; \
+			$(GREP) '["*:<>?\\|]')"; \
 		test -z "$$bad" || { \
 		echo >&2 "non-portable file name(s): $$bad"; exit 1; }
 
Previous: Jeffrey WaltonNext: Jeffrey Walton
Message 6 of 13 in “Solaris and sed: Too many commands, last: s/\n//”
  1. Jeffrey WaltonMar 11, 2019
  2. Eric SunshineMar 11, 2019
  3. Jeffrey WaltonMar 11, 2019
  4. Eric SunshineMar 11, 2019
  5. Jeffrey WaltonMar 12, 2019
  6. Jeffrey WaltonMar 12, 2019
  7. Jeffrey WaltonMar 12, 2019
  8. Jeffrey WaltonMar 12, 2019
  9. Eric SunshineMar 12, 2019
  10. Jeffrey WaltonMar 12, 2019
  11. Jeffrey WaltonMar 11, 2019
  12. Jeffrey WaltonMar 12, 2019
  13. Ævar Arnfjörð BjarmasonMar 12, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.